public void Words() { #region Words MyStringReader r = new MyStringReader(" (skip leading,\r\n\tand trailing\vwhitespace) "); string[] words = r.Words().ToArray(); Assert.IsTrue(r.WasDisposed); Assert.AreEqual(5, words.Length); Assert.AreEqual("(skip", words [0]); Assert.AreEqual("leading,", words [1]); Assert.AreEqual("and", words [2]); Assert.AreEqual("trailing", words [3]); Assert.AreEqual("whitespace)", words [4]); r = new MyStringReader("notext"); words = r.Words(TextReaderRocksOptions.None).ToArray(); Assert.IsFalse(r.WasDisposed); Assert.AreEqual(1, words.Length); Assert.AreEqual("notext", words [0]); r = new MyStringReader("1 2 3 4"); Assert.AreEqual("1", r.Words().First()); Assert.AreEqual("2", r.Words().First()); Assert.AreEqual("3", r.Words().First()); Assert.AreEqual("4", r.Words().First()); #endregion }
public void Words() { #region Words MyStringReader r = new MyStringReader (" (skip leading,\r\n\tand trailing\vwhitespace) "); string[] words = r.Words ().ToArray (); Assert.IsTrue (r.WasDisposed); Assert.AreEqual (5, words.Length); Assert.AreEqual ("(skip", words [0]); Assert.AreEqual ("leading,", words [1]); Assert.AreEqual ("and", words [2]); Assert.AreEqual ("trailing", words [3]); Assert.AreEqual ("whitespace)", words [4]); r = new MyStringReader ("notext"); words = r.Words (TextReaderCodaOptions.None).ToArray (); Assert.IsFalse (r.WasDisposed); Assert.AreEqual (1, words.Length); Assert.AreEqual ("notext", words [0]); r = new MyStringReader ("1 2 3 4"); Assert.AreEqual ("1", r.Words ().First ()); Assert.AreEqual ("2", r.Words ().First ()); Assert.AreEqual ("3", r.Words ().First ()); Assert.AreEqual ("4", r.Words ().First ()); #endregion }