예제 #1
0
        public void CustomDelimiaters()
        {
            Tokenizer t = new Tokenizer("my|custom|delimiter", "|");
            Assert.AreEqual(3,t.Count);
            Assert.IsTrue(t.HasMoreTokens());
            Assert.AreEqual("my", t.NextToken());
            Assert.AreEqual("custom", t.NextToken());
            Assert.AreEqual("delimiter", t.NextToken());

            Assert.IsFalse(t.HasMoreTokens());
            Assert.AreEqual(0, t.Count);
        }
예제 #2
0
        public void MixedInteriorDelimiters()
        {
            Tokenizer t = new Tokenizer("some\tstring and\rvalues");
            Assert.AreEqual(4, t.Count);
            Assert.IsTrue(t.HasMoreTokens());
            Assert.AreEqual("some",t.NextToken());
            Assert.AreEqual("string",t.NextToken());
            Assert.AreEqual("and",t.NextToken());
            Assert.AreEqual("values",t.NextToken());

            Assert.IsFalse(t.HasMoreTokens());
            Assert.AreEqual(0, t.Count);
        }
예제 #3
0
        public void CustomDelimiaters()
        {
            Tokenizer t = new Tokenizer("my|custom|delimiter", "|");

            Assert.AreEqual(3, t.Count);
            Assert.IsTrue(t.HasMoreTokens());
            Assert.AreEqual("my", t.NextToken());
            Assert.AreEqual("custom", t.NextToken());
            Assert.AreEqual("delimiter", t.NextToken());

            Assert.IsFalse(t.HasMoreTokens());
            Assert.AreEqual(0, t.Count);
        }
예제 #4
0
        public void InteriorSingleDelimiter()
        {
            Tokenizer t = new Tokenizer("some\tstring");
            Assert.AreEqual(2, t.Count);

            Assert.AreEqual("some", t.NextToken());

            Assert.AreEqual(1, t.Count);
            Assert.IsTrue(t.HasMoreTokens());

            Assert.AreEqual("string", t.NextToken());

            Assert.IsFalse(t.HasMoreTokens());
        }
예제 #5
0
        public void MixedInteriorDelimiters()
        {
            Tokenizer t = new Tokenizer("some\tstring and\rvalues");

            Assert.AreEqual(4, t.Count);
            Assert.IsTrue(t.HasMoreTokens());
            Assert.AreEqual("some", t.NextToken());
            Assert.AreEqual("string", t.NextToken());
            Assert.AreEqual("and", t.NextToken());
            Assert.AreEqual("values", t.NextToken());

            Assert.IsFalse(t.HasMoreTokens());
            Assert.AreEqual(0, t.Count);
        }
예제 #6
0
        public void InteriorSingleDelimiter()
        {
            Tokenizer t = new Tokenizer("some\tstring");

            Assert.AreEqual(2, t.Count);

            Assert.AreEqual("some", t.NextToken());

            Assert.AreEqual(1, t.Count);
            Assert.IsTrue(t.HasMoreTokens());

            Assert.AreEqual("string", t.NextToken());

            Assert.IsFalse(t.HasMoreTokens());
        }
예제 #7
0
        public void PassCustomDelimiter()
        {
            Tokenizer t = new Tokenizer("normal delimiters|then|custom");

            Assert.AreEqual(2, t.Count);
            Assert.IsTrue(t.HasMoreTokens());
            Assert.AreEqual("normal", t.NextToken());


            Assert.AreEqual(" delimiters", t.NextToken("|"));
            Assert.AreEqual("then", t.NextToken("|"));
            Assert.AreEqual("custom", t.NextToken("|"));

            Assert.IsFalse(t.HasMoreTokens());
            Assert.AreEqual(0, t.Count);
        }
예제 #8
0
 public void EndingDelimiter()
 {
     Tokenizer t = new Tokenizer("somestring\t");
     Assert.AreEqual(1, t.Count);
     Assert.IsTrue(t.HasMoreTokens());
     Assert.AreEqual("somestring", t.NextToken());
     Assert.IsFalse(t.HasMoreTokens());
 }
예제 #9
0
        public void EndingDelimiter()
        {
            Tokenizer t = new Tokenizer("somestring\t");

            Assert.AreEqual(1, t.Count);
            Assert.IsTrue(t.HasMoreTokens());
            Assert.AreEqual("somestring", t.NextToken());
            Assert.IsFalse(t.HasMoreTokens());
        }
예제 #10
0
        public void StringWithNoTokens()
        {
            Tokenizer t = new Tokenizer("somestring");

            Assert.AreEqual(1, t.Count);
            Assert.IsTrue(t.HasMoreTokens());

            Assert.AreEqual("somestring", t.NextToken());
        }
예제 #11
0
        public void ReturnDelimiters()
        {
            Tokenizer t = new Tokenizer("this is a test string", " ", true);

            Assert.AreEqual(9, t.Count);
            Assert.IsTrue(t.HasMoreTokens());

            Assert.AreEqual("this", t.NextToken());
            Assert.AreEqual(" ", t.NextToken());
            Assert.AreEqual("is", t.NextToken());
            Assert.AreEqual(" ", t.NextToken());
            Assert.AreEqual("a", t.NextToken());
            Assert.AreEqual(" ", t.NextToken());
            Assert.AreEqual("test", t.NextToken());
            Assert.AreEqual(" ", t.NextToken());
            Assert.AreEqual("string", t.NextToken());

            Assert.IsFalse(t.HasMoreTokens());
            Assert.AreEqual(0, t.Count);
        }
예제 #12
0
        public void PassCustomDelimiter()
        {
            Tokenizer t = new Tokenizer("normal delimiters|then|custom");
            Assert.AreEqual(2, t.Count);
            Assert.IsTrue(t.HasMoreTokens());
            Assert.AreEqual("normal", t.NextToken());

            Assert.AreEqual(" delimiters", t.NextToken("|"));
            Assert.AreEqual("then", t.NextToken("|"));
            Assert.AreEqual("custom", t.NextToken("|"));

            Assert.IsFalse(t.HasMoreTokens());
            Assert.AreEqual(0, t.Count);
        }
예제 #13
0
        public void StringWithNoTokens()
        {
            Tokenizer t = new Tokenizer("somestring");
            Assert.AreEqual(1, t.Count);
            Assert.IsTrue(t.HasMoreTokens());

            Assert.AreEqual("somestring", t.NextToken());
        }
예제 #14
0
        public void ReturnDelimiters()
        {
            Tokenizer t = new Tokenizer("this is a test string", " ", true);
            Assert.AreEqual(9, t.Count);
            Assert.IsTrue(t.HasMoreTokens());

            Assert.AreEqual("this", t.NextToken());
            Assert.AreEqual(" ", t.NextToken());
            Assert.AreEqual("is", t.NextToken());
            Assert.AreEqual(" ", t.NextToken());
            Assert.AreEqual("a", t.NextToken());
            Assert.AreEqual(" ", t.NextToken());
            Assert.AreEqual("test", t.NextToken());
            Assert.AreEqual(" ", t.NextToken());
            Assert.AreEqual("string", t.NextToken());

            Assert.IsFalse(t.HasMoreTokens());
            Assert.AreEqual(0, t.Count);
        }