コード例 #1
0
        public void EndsWithCodeUnit(string s, char c)
        {
            Utf8String u8s      = new Utf8String(s);
            byte       codeUnit = (byte)c;

            Assert.Equal(s.EndsWith(c.ToString()), u8s.EndsWith(codeUnit));
        }
コード例 #2
0
        public void EndsWithUtf8String(string s, string pattern)
        {
            Utf8String u8s       = new Utf8String(s);
            Utf8String u8pattern = new Utf8String(pattern);

            Assert.Equal(s.EndsWith(pattern), u8s.EndsWith(u8pattern));
        }
コード例 #3
0
        public static void Searching_StandaloneSurrogate_Fails()
        {
            Utf8String utf8String = u8("\ud800\udfff");

            Assert.False(utf8String.Contains('\ud800'));
            Assert.False(utf8String.Contains('\udfff'));

            Assert.Equal(-1, utf8String.IndexOf('\ud800'));
            Assert.Equal(-1, utf8String.IndexOf('\udfff'));

            Assert.False(utf8String.StartsWith('\ud800'));
            Assert.False(utf8String.StartsWith('\udfff'));

            Assert.False(utf8String.EndsWith('\ud800'));
            Assert.False(utf8String.EndsWith('\udfff'));
        }
コード例 #4
0
        public void EndsWithUtf8String(string s, string pattern)
        {
            Utf8String u8s = new Utf8String(s);
            Utf8String u8pattern = new Utf8String(pattern);

            Assert.Equal(s.EndsWith(pattern), u8s.EndsWith(u8pattern));
        }
コード例 #5
0
        public static void StartsWith_And_EndsWith_CharRune_Ordinal(Utf8String utf8String, Rune searchValue, int expectedIndex)
        {
            // StartsWith

            if (searchValue.IsBmp)
            {
                Assert.Equal(expectedIndex == 0, utf8String.StartsWith((char)searchValue.Value));
            }
            Assert.Equal(expectedIndex == 0, utf8String.StartsWith(searchValue));

            // EndsWith

            bool endsWithExpectedValue = (expectedIndex >= 0) && (expectedIndex + searchValue.Utf8SequenceLength) == utf8String.Length;

            if (searchValue.IsBmp)
            {
                Assert.Equal(endsWithExpectedValue, utf8String.EndsWith((char)searchValue.Value));
            }
            Assert.Equal(endsWithExpectedValue, utf8String.EndsWith(searchValue));
        }
コード例 #6
0
ファイル: RandomTests.cs プロジェクト: jkotas/corefxlab
 public void EndsWithCodeUnit(string s, char c)
 {
     Utf8String u8s = new Utf8String(s);
     Utf8CodeUnit codeUnit = (Utf8CodeUnit)(byte)c;
     Assert.Equal(s.EndsWith(c.ToString()), u8s.EndsWith(codeUnit));
 }
コード例 #7
0
ファイル: JsonReader.cs プロジェクト: Anniepoh/corefxlab
 private static int GetNumOfBackSlashesAtEndOfString(Utf8String str)
 {
     var numOfBackSlashes = 0;
     while (str.EndsWith(new Utf8String("\\")))
     {
         str = str.Substring(0, str.Length - 1);
         numOfBackSlashes++;
     }
     return numOfBackSlashes;
 }