Exemple #1
0
        public void Reads()
        {
            TextReader s = new StringReader (" pi  (True 42 C 3.14159) e (Y  1 2 (/3 4) 4 2.71  )  ");
            var categories = new Func<char?, char, bool>[] {
                (_, c) => char.IsLetterOrDigit (c) || c == '.',
                (_, c) => c == '+' || c == '-' || c == '*' || c == '/',
                (_, c) => !char.IsWhiteSpace (c),
            };
            var reader = new TextValueReader (s.Tokens (categories));

            TvrData1 a;
            TvrData2 b;
            string p, e;
            reader.Read (out p)
                .Read (out a)
                .Read (out e)
                .Read (out b);

            Assert.AreEqual ("pi", p);
            Assert.AreEqual ("e", e);

            Assert.AreEqual (true,      a.A);
            Assert.AreEqual ((byte) 42, a.B);
            Assert.AreEqual ('C',       a.C);
            Assert.AreEqual (3.14159,   a.D);

            Assert.AreEqual ("Y",   b.F);
            Assert.AreEqual (1,     b.A);
            Assert.AreEqual (2,     b.B);
            Assert.AreEqual ("3",   b.O.left);
            Assert.AreEqual ('/',   b.O.op);
            Assert.AreEqual ("4",   b.O.right);
            Assert.AreEqual (4,     b.C);
            Assert.AreEqual (2.71f, b.D);
        }
Exemple #2
0
 public void Tokens_OptionsInvalid()
 {
     TextReader s = new StringReader ("");
     s.Tokens ((TextReaderCodaOptions) (-1));
 }
Exemple #3
0
 public void Tokens_FullCategoriesNull()
 {
     TextReader                         s = new StringReader ("");
     Func<char?, char, bool>[] categories = null;
     IEnumerable<string>                r = s.Tokens (TextReaderCodaOptions.None, categories);
     Ignore (r);
 }
Exemple #4
0
 public void Tokens_CategoriesEmpty()
 {
     TextReader                         s = new StringReader ("");
     Func<char?, char, bool>[] categories = new Func<char?, char, bool>[0];
     IEnumerable<string>                r = s.Tokens (categories);
     Ignore (r);
 }
Exemple #5
0
 public void Tokens_FullCategoriesEmpty()
 {
     TextReader                         s = new StringReader ("");
     Func<char?, char, bool>[] categories = new Func<char?, char, bool>[0];
     IEnumerable<string>                r = s.Tokens (TextReaderRocksOptions.None, categories);
 }
Exemple #6
0
 public void Tokens_CategoriesNull()
 {
     TextReader                         s = new StringReader ("");
     Func<char?, char, bool>[] categories = null;
     IEnumerable<string>                r = s.Tokens (categories);
 }