public void ConstructorTest1() { StringTokenizer tok = new StringTokenizer("1\t2\n3\r4\f5 6", (Regex)null); Assert.AreEqual(tok.CountTokens(), 6); }
public void ConstructorTest4() { StringTokenizer tok = new StringTokenizer("A true Klingon warrior does NOT comment his code!", " ", false); Assert.AreEqual(tok.CountTokens(), 9); }
public void TokenizeTest() { string target_str1 = null; Regex target_pattern1 = null; bool tokenizeAllParam = false; StringTokenizer target = new StringTokenizer(target_str1, target_pattern1, tokenizeAllParam); StringTokenizer_Accessor accessor = new StringTokenizer_Accessor(""); string tokenize_str2 = null; Regex tokenize_pattern2 = null; accessor.tokenize(tokenize_str2, tokenize_pattern2); }
public void ConstructorTest() { StringTokenizer tok = new StringTokenizer(null); Assert.AreEqual(tok.CountTokens(), 0); }
public void ReturnAllTest() { string str = "ABC|DEF|123|"; StringTokenizer target = new StringTokenizer(str, "|"); List<string> expected = new List<string>(); expected.Add("ABC"); expected.Add("DEF"); expected.Add("123"); Collection<string> actual = target.ReturnAll(); CollectionAssert.AreEqual(expected, actual, "Utilities.StringTokenizer.ReturnAll did not return the expected value."); }
public void PeekTest() { string str = "ABC|DEF|123"; Regex pattern = new Regex("|"); bool tokenizeAllParam = false; StringTokenizer target = new StringTokenizer(str, pattern, tokenizeAllParam); string expected = "A"; string actual; actual = target.Peek(); Assert.AreEqual(expected, actual, "Utilities.StringTokenizer.Peek did not return the expected value."); }
public void NextTokenTest() { string str = "The first thing we do, let's kill all the lawyers."; StringTokenizer tok = new StringTokenizer(str); Assert.IsTrue(tok.NextToken().Equals("The")); Assert.IsTrue(tok.NextToken().Equals("first")); Assert.IsTrue(tok.NextToken().Equals("thing")); Assert.IsTrue(tok.NextToken().Equals("we")); Assert.IsTrue(tok.NextToken().Equals("do,")); Assert.IsTrue(tok.NextToken().Equals("let's")); Assert.IsTrue(tok.NextToken().Equals("kill")); Assert.IsTrue(tok.NextToken().Equals("all")); Assert.IsTrue(tok.NextToken().Equals("the")); Assert.IsTrue(tok.NextToken().Equals("lawyers.")); Assert.IsTrue(tok.NextToken() == null); str = "I doubt, therefore I might be."; tok = new StringTokenizer(str, ","); Assert.IsTrue(tok.NextToken().Equals("I doubt")); Assert.IsTrue(tok.NextToken().Equals(" therefore I might be.")); Assert.IsTrue(tok.NextToken() == null); str = "Meow mix, meow mix, please deliver!"; Regex pattern = new Regex(", "); tok = new StringTokenizer(str, pattern); Assert.IsTrue(tok.NextToken().Equals("Meow mix")); Assert.IsTrue(tok.NextToken().Equals("meow mix")); Assert.IsTrue(tok.NextToken().Equals("please deliver!")); Assert.IsTrue(tok.NextToken() == null); str = "aaa"; pattern = new Regex("aa"); tok = new StringTokenizer(str, pattern); Assert.IsTrue(tok.NextToken().Equals("a")); tok = new StringTokenizer(""); Assert.IsTrue(tok.NextToken() == null); tok = new StringTokenizer("Meow", "!"); Assert.IsTrue(tok.NextToken().Equals("Meow")); Assert.IsTrue(tok.NextToken() == null); }
public void HasMoreTokensTest() { string str = "Fhqwhgads"; StringTokenizer tok = new StringTokenizer(str); Assert.IsTrue(tok.HasMoreTokens()); tok.NextToken(); Assert.IsFalse(tok.HasMoreTokens()); tok = new StringTokenizer(""); Assert.IsFalse(tok.HasMoreTokens()); }
public void CountTokensTest() { string str = "1 2 3 4 5"; StringTokenizer tok = new StringTokenizer(str); Assert.AreEqual(tok.CountTokens(), 5); str = "1 2\n\f3 \t4 5 "; tok = new StringTokenizer(str); Assert.AreEqual(tok.CountTokens(), 5); tok = new StringTokenizer(""); Assert.AreEqual(tok.CountTokens(), 0); str = "0 0 1 2 3 4 5"; tok = new StringTokenizer(str); tok.NextToken(); tok.NextToken(); Assert.AreEqual(tok.CountTokens(), 5); }