コード例 #1
0
ファイル: TokenizerFixture.cs プロジェクト: snosrap/nhapi
        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
ファイル: TokenizerFixture.cs プロジェクト: snosrap/nhapi
        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
ファイル: TokenizerFixture.cs プロジェクト: snosrap/nhapi
        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
ファイル: TokenizerFixture.cs プロジェクト: snosrap/nhapi
 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
ファイル: TokenizerFixture.cs プロジェクト: snosrap/nhapi
        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
ファイル: TokenizerFixture.cs プロジェクト: snosrap/nhapi
        public void StringWithNoTokens()
        {
            Tokenizer t = new Tokenizer("somestring");
            Assert.AreEqual(1, t.Count);
            Assert.IsTrue(t.HasMoreTokens());

            Assert.AreEqual("somestring", t.NextToken());
        }
コード例 #14
0
ファイル: TokenizerFixture.cs プロジェクト: snosrap/nhapi
        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);
        }