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')); }
public static void Contains_And_IndexOf_CharRune_Ordinal(Utf8String utf8String, Rune searchValue, int expectedIndex) { // Contains if (searchValue.IsBmp) { Assert.Equal(expectedIndex >= 0, utf8String.Contains((char)searchValue.Value)); } Assert.Equal(expectedIndex >= 0, utf8String.Contains(searchValue)); // IndexOf if (searchValue.IsBmp) { Assert.Equal(expectedIndex, utf8String.IndexOf((char)searchValue.Value)); } Assert.Equal(expectedIndex, utf8String.IndexOf(searchValue)); }