Example #1
0
        public void CharacterStreamConstructorTest_StringReader()
        {
            StringReader testInput = new StringReader("Test");
            StreamLocation expectedLocation = new StreamLocation(0, 1, 1);

            CharacterScanner sut = new CharacterScanner(testInput);

            Assert.AreEqual(false, sut.IsEOF(), "Should not be at EOF");
            Assert.AreEqual(true, sut.HasNext(), "Should have next");
            Assert.AreEqual(expectedLocation, sut.Location);
            Assert.AreEqual('T', sut.Peek());
        }
Example #2
0
        public void CharacterStreamIsEOFHasNextTest_NotEOF()
        {
            string testInput = "a";
            bool expectEOF = false;
            StreamLocation expectedLocation = new StreamLocation(0, 1, 1);

            CharacterScanner sut = new CharacterScanner(testInput);
            sut.Start();

            Assert.AreEqual(expectEOF, sut.IsEOF(), "EOF unexpected");
            Assert.AreEqual(!expectEOF, sut.HasNext(), "HasNext expected");
            Assert.AreEqual(expectedLocation, sut.Location);
        }
Example #3
0
        public void CharacterStreamIsEOFHasNextTest_AtEOF()
        {
            string testInput = "a";
            bool expectEOF = true;
            StreamLocation expectedLocation = new StreamLocation(1, 1, 2);

            CharacterScanner sut = new CharacterScanner(testInput);
            sut.Start();
            sut.Consume();

            Assert.AreEqual(expectEOF, sut.IsEOF(), "EOF expected");
            Assert.AreEqual(!expectEOF, sut.HasNext(), "HasNext unexpected");
            Assert.AreEqual(expectedLocation, sut.Location);
        }