本文整理汇总了C#中Utf8String.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# Utf8String.IndexOf方法的具体用法?C# Utf8String.IndexOf怎么用?C# Utf8String.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utf8String
的用法示例。
在下文中一共展示了Utf8String.IndexOf方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IndexOfUtf8CharacterTest
public void IndexOfUtf8CharacterTest(string s, char character)
{
int expected = s.IndexOf(character);
Utf8String u8s = new Utf8String(s);
Utf8CodeUnit u8codeUnit = (Utf8CodeUnit)(byte)(character);
Assert.Equal(expected, u8s.IndexOf(u8codeUnit));
}
示例2: IndexOfUnicodeCodePoint
public void IndexOfUnicodeCodePoint(int expected, string s, uint codePointValue)
{
Utf8String u8s = new Utf8String(s);
UnicodeCodePoint codePoint = (UnicodeCodePoint)codePointValue;
Assert.Equal(expected, u8s.IndexOf(codePoint));
}
示例3: IndexOfTests
public void IndexOfTests(int expected, string s, string substring)
{
Utf8String utf8s = new Utf8String(s);
Utf8String utf8substring = new Utf8String(substring);
Assert.Equal(expected, utf8s.IndexOf(utf8substring));
}
示例4: IndexOfNonOccuringSingleCodePointConstructFromSpan
public unsafe void IndexOfNonOccuringSingleCodePointConstructFromSpan()
{
TestCase[] testCases = new TestCase[] {
new TestCase(GetRandomString(5, 32, 126), "Short ASCII string", 5000000),
new TestCase(GetRandomString(5, 32, 0xD7FF), "Short string", 5000000),
new TestCase(GetRandomString(50000, 32, 126), "Long ASCII string", 500),
new TestCase(GetRandomString(50000, 32, 0xD7FF), "Long string", 500)
};
foreach (TestCase testData in testCases)
{
string s = testData.String;
Utf8String utf8s = new Utf8String(s);
fixed (byte* bytes = utf8s.CopyBytes())
{
utf8s = new Utf8String(new Span<byte>(bytes, utf8s.Length));
int iterations = testData.Iterations;
_timer.Restart();
while (iterations-- != 0)
{
int p = utf8s.IndexOf((UnicodeCodePoint)31);
}
PrintTime(testData);
}
}
}
示例5: IndexOfNonOccuringSingleCodeUnitConstructFromByteArray
public void IndexOfNonOccuringSingleCodeUnitConstructFromByteArray()
{
TestCase[] testCases = new TestCase[] {
new TestCase(GetRandomString(5, 32, 126), "Short ASCII string", 30000000),
new TestCase(GetRandomString(5, 32, 0xD7FF), "Short string", 30000000),
new TestCase(GetRandomString(50000, 32, 126), "Long ASCII string", 3000),
new TestCase(GetRandomString(50000, 32, 0xD7FF), "Long string", 3000)
};
foreach (TestCase testData in testCases)
{
string s = testData.String;
Utf8String utf8s = new Utf8String(s);
utf8s = new Utf8String(utf8s.CopyBytes());
int iterations = testData.Iterations;
_timer.Restart();
while (iterations-- != 0)
{
int p = utf8s.IndexOf((byte)31);
}
PrintTime(testData);
}
}
示例6: IndexOfNonOccuringSingleCodeUnitConstructFromSpan
public unsafe void IndexOfNonOccuringSingleCodeUnitConstructFromSpan()
{
foreach (StringWithDescription testData in StringsWithDescription())
{
string s = testData.String;
Utf8String utf8s = new Utf8String(s);
fixed (byte* bytes = utf8s.CopyBytes())
{
utf8s = new Utf8String(new ByteSpan(bytes, utf8s.Length));
int iterations = testData.Iterations;
_timer.Restart();
while (iterations-- != 0)
{
int p = utf8s.IndexOf((Utf8CodeUnit)31);
}
PrintTime(testData);
}
}
}
示例7: IndexOfNonOccuringSingleCodeUnitConstructFromByteArray
public void IndexOfNonOccuringSingleCodeUnitConstructFromByteArray()
{
foreach (StringWithDescription testData in StringsWithDescription())
{
string s = testData.String;
Utf8String utf8s = new Utf8String(s);
utf8s = new Utf8String(utf8s.CopyBytes());
int iterations = testData.Iterations;
_timer.Restart();
while (iterations-- != 0)
{
int p = utf8s.IndexOf((Utf8CodeUnit)31);
}
PrintTime(testData);
}
}