Ejemplo n.º 1
0
        public void is_a_string_token()
        {
            StringTokenizer st = new StringTokenizer("\"\"coucou\"a string\" 1454 toto");
            string          s;

            // we must have ""
            Assert.That(st.IsString(out s));
            Assert.That(s, Is.EqualTo(""));
            // we must have coucou
            Assert.That(st.MatchIdentifier("coucou"));
            // we must have ""
            Assert.That(st.IsString(out s) && s == "a string");

            Assert.That(st.IsString(out s), Is.False);
            Assert.That(st.IsIdentifier(out s), Is.False);
            Assert.That(st.Match(TokenType.OpenCurly), Is.False);
            Assert.That(st.MatchIdentifier("b"), Is.False);
            int i;

            Assert.That(st.IsInteger(out i) && i == 1454);

            Assert.That(st.IsString(out s), Is.False);
            Assert.That(st.IsInteger(out i), Is.False);
            Assert.That(st.Match(TokenType.SemiColon), Is.False);
            Assert.That(st.MatchIdentifier("YOYO"), Is.False);

            Assert.That(st.MatchIdentifier("toto"));
            Assert.That(st.Match(TokenType.EndOfInput));
        }