public void ReadWord_OnlyWhitespaceFollowedByNewline() { var inp = new MockInput(" \t \t \t\t\t \n"); var r = new LineReader(inp); List <string> words = new List <string>(); for (int i = 0; i < 2; i++) { words.Add(r.ReadWord()); } CollectionAssert.AreEqual(new [] { "\n", null }, words); }
public void ReadWord_OnlyNonWhitespace() { string line = "ThisisoneLonWordThatTheReaderShouldReadAsAWord"; var inp = new MockInput(line); var r = new LineReader(inp); List <string> words = new List <string>(); for (int i = 0; i < 2; i++) { words.Add(r.ReadWord()); } CollectionAssert.AreEqual(new [] { line, null }, words); }
public void ReadWord_WhiteSpaceFollowedByWord() { string word = "SomeWordToRead"; string line = " \t\t \t " + word; var inp = new MockInput(line); var r = new LineReader(inp); List <string> words = new List <string>(); for (int i = 0; i < 2; i++) { words.Add(r.ReadWord()); } CollectionAssert.AreEqual(new [] { word, null }, words); }
public void ReadWord_WordWhitespaceNewlineWhitespaceWord() { string word = "SomeWordToRead"; string word2 = "SomeOtherWord"; string line = word + "\t \t\t\n \t " + word2; var inp = new MockInput(line); var r = new LineReader(inp); List <string> words = new List <string>(); for (int i = 0; i < 4; i++) { words.Add(r.ReadWord()); } CollectionAssert.AreEqual(new [] { word, "\n", word2, null }, words); }