Exemplo n.º 1
0
        public void ConsumeLetterThenDigitSequence()
        {
            CharacterReader r = new CharacterReader("One12 Two &bar; qux");

            Assert.AreEqual("One12", r.ConsumeLetterThenDigitSequence());
            Assert.AreEqual(' ', r.Consume());
            Assert.AreEqual("Two", r.ConsumeLetterThenDigitSequence());
            Assert.AreEqual(" &bar; qux", r.ConsumeToEnd());
        }
Exemplo n.º 2
0
        public void ConsumeToEnd()
        {
            string          @in   = "one two three";
            CharacterReader r     = new CharacterReader(@in);
            string          toEnd = r.ConsumeToEnd();

            Assert.AreEqual(@in, toEnd);
            Assert.IsTrue(r.IsEmpty());
        }
Exemplo n.º 3
0
        public void ConsumeLetterSequence()
        {
            CharacterReader r = new CharacterReader("One &bar; qux");

            Assert.AreEqual("One", r.ConsumeLetterSequence());
            Assert.AreEqual(" &", r.ConsumeTo("bar;"));
            Assert.AreEqual("bar", r.ConsumeLetterSequence());
            Assert.AreEqual("; qux", r.ConsumeToEnd());
        }
Exemplo n.º 4
0
        public void consumeToEnd()
        {
            string          input = "one two three";
            CharacterReader r     = new CharacterReader(input);
            String          toEnd = r.ConsumeToEnd();

            Assert.AreEqual(input, toEnd);
            Assert.IsTrue(r.IsEmpty());
        }
Exemplo n.º 5
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"));
        }
Exemplo n.º 6
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'));
        }
Exemplo n.º 7
0
        public void Matches()
        {
            CharacterReader r = new CharacterReader("One Two Three");

            Assert.IsTrue(r.Matches('O'));
            Assert.IsTrue(r.Matches("One Two Three"));
            Assert.IsTrue(r.Matches("One"));
            Assert.IsFalse(r.Matches("one"));
            Assert.AreEqual('O', r.Consume());
            Assert.IsFalse(r.Matches("One"));
            Assert.IsTrue(r.Matches("ne Two Three"));
            Assert.IsFalse(r.Matches("ne Two Three Four"));
            Assert.AreEqual("ne Two Three", r.ConsumeToEnd());
            Assert.IsFalse(r.Matches("ne"));
        }
Exemplo n.º 8
0
        public void MatchesIgnoreCase()
        {
            CharacterReader r = new CharacterReader("One Two Three");

            Assert.IsTrue(r.MatchesIgnoreCase("O"));
            Assert.IsTrue(r.MatchesIgnoreCase("o"));
            Assert.IsTrue(r.Matches('O'));
            Assert.IsFalse(r.Matches('o'));
            Assert.IsTrue(r.MatchesIgnoreCase("One Two Three"));
            Assert.IsTrue(r.MatchesIgnoreCase("ONE two THREE"));
            Assert.IsTrue(r.MatchesIgnoreCase("One"));
            Assert.IsTrue(r.MatchesIgnoreCase("one"));
            Assert.AreEqual('O', r.Consume());
            Assert.IsFalse(r.MatchesIgnoreCase("One"));
            Assert.IsTrue(r.MatchesIgnoreCase("NE Two Three"));
            Assert.IsFalse(r.MatchesIgnoreCase("ne Two Three Four"));
            Assert.AreEqual("ne Two Three", r.ConsumeToEnd());
            Assert.IsFalse(r.MatchesIgnoreCase("ne"));
        }