示例#1
0
 public void StaticIndexOfChar()
 {
     Assert.Equal(-1, CharUtil.IndexOf(null, 'a', 0));
     Assert.Equal(-1, CharUtil.IndexOf((AsciiString)"", 'a', 0));
     Assert.Equal(-1, CharUtil.IndexOf((AsciiString)"abc", 'd', 0));
     Assert.Equal(-1, CharUtil.IndexOf((AsciiString)"aabaabaa", 'A', 0));
     Assert.Equal(0, CharUtil.IndexOf((AsciiString)"aabaabaa", 'a', 0));
     Assert.Equal(1, CharUtil.IndexOf((AsciiString)"aabaabaa", 'a', 1));
     Assert.Equal(3, CharUtil.IndexOf((AsciiString)"aabaabaa", 'a', 2));
     Assert.Equal(3, CharUtil.IndexOf((AsciiString)"aabdabaa", 'd', 1));
 }
示例#2
0
 public void IndexOfChar()
 {
     Assert.Equal(-1, CharUtil.IndexOf(null, 'a', 0));
     Assert.Equal(-1, ((AsciiString)"").IndexOf('a', 0));
     Assert.Equal(-1, ((AsciiString)"abc").IndexOf('d', 0));
     Assert.Equal(-1, ((AsciiString)"aabaabaa").IndexOf('A', 0));
     Assert.Equal(0, ((AsciiString)"aabaabaa").IndexOf('a', 0));
     Assert.Equal(1, ((AsciiString)"aabaabaa").IndexOf('a', 1));
     Assert.Equal(3, ((AsciiString)"aabaabaa").IndexOf('a', 2));
     Assert.Equal(3, ((AsciiString)"aabdabaa").IndexOf('d', 1));
 }
 public void IndexOfChar()
 {
     Assert.Equal(-1, CharUtil.IndexOf(null, 'a', 0));
     Assert.Equal(-1, ((AsciiString)"").IndexOf('a', 0));
     Assert.Equal(-1, ((AsciiString)"abc").IndexOf('d', 0));
     Assert.Equal(-1, ((AsciiString)"aabaabaa").IndexOf('A', 0));
     Assert.Equal(0, ((AsciiString)"aabaabaa").IndexOf('a', 0));
     Assert.Equal(1, ((AsciiString)"aabaabaa").IndexOf('a', 1));
     Assert.Equal(3, ((AsciiString)"aabaabaa").IndexOf('a', 2));
     Assert.Equal(3, ((AsciiString)"aabdabaa").IndexOf('d', 1));
     Assert.Equal(1, new AsciiString("abcd", 1, 2).IndexOf('c', 0));
     Assert.Equal(2, new AsciiString("abcd", 1, 3).IndexOf('d', 2));
     Assert.Equal(0, new AsciiString("abcd", 1, 2).IndexOf('b', 0));
     Assert.Equal(-1, new AsciiString("abcd", 0, 2).IndexOf('c', 0));
     Assert.Equal(-1, new AsciiString("abcd", 1, 3).IndexOf('a', 0));
 }
 public int IndexOf(char ch, int start = 0) => CharUtil.IndexOf(this, ch, start);