示例#1
0
        public void NextIndexOfChar() {
        string @in = "blah blah";
        CharacterReader r = new CharacterReader(@in);

        Assert.AreEqual(-1, r.NextIndexOf('x'));
        Assert.AreEqual(3, r.NextIndexOf('h'));
        string pull = r.ConsumeTo('h');
        Assert.AreEqual("bla", pull);
        r.Consume();
        Assert.AreEqual(2, r.NextIndexOf('l'));
        Assert.AreEqual(" blah", r.ConsumeToEnd());
        Assert.AreEqual(-1, r.NextIndexOf('x'));
    }
示例#2
0
        public void NextIndexOfString() {
        string @in = "One Two something Two Three Four";
        CharacterReader r = new CharacterReader(@in);

        Assert.AreEqual(-1, r.NextIndexOf("Foo"));
        Assert.AreEqual(4, r.NextIndexOf("Two"));
        Assert.AreEqual("One Two ", r.ConsumeTo("something"));
        Assert.AreEqual(10, r.NextIndexOf("Two"));
        Assert.AreEqual("something Two Three Four", r.ConsumeToEnd());
        Assert.AreEqual(-1, r.NextIndexOf("Two"));
    }
示例#3
0
 public void NextIndexOfUnmatched()
 {
     CharacterReader r = new CharacterReader("<[[one]]");
     Assert.AreEqual(-1, r.NextIndexOf("]]>"));
 }