private static void CompareResults(XMLBeginEndIterator <string> iterator, params string[] expectedResults) { List <string> results = GetResults(iterator); NUnit.Framework.Assert.AreEqual(expectedResults.Length, results.Count); for (int i = 0; i < expectedResults.Length; ++i) { NUnit.Framework.Assert.AreEqual(expectedResults[i], results[i]); } }
// Copyright 2010, Stanford NLP // Test that the XMLBeginEndIterator will successfully find a bunch of // text inside xml tags. // TODO: can add tests for the String->Object conversion and some of // the other options the XMLBeginEndIterator has private static List <string> GetResults(XMLBeginEndIterator <string> iterator) { List <string> results = new List <string>(); while (iterator.MoveNext()) { results.Add(iterator.Current); } return(results); }
/// <exception cref="System.IO.IOException"/> public static void Main(string[] args) { if (args.Length < 3) { log.Info("usage: XMLBeginEndIterator file element keepInternalBoolean"); return; } Reader @in = new FileReader(args[0]); IEnumerator <string> iter = new XMLBeginEndIterator <string>(@in, args[1], Sharpen.Runtime.EqualsIgnoreCase(args[2], "true")); while (iter.MoveNext()) { string s = iter.Current; System.Console.Out.WriteLine("*************************************************"); System.Console.Out.WriteLine(s); } @in.Close(); }
public virtual void TestInternalTags() { XMLBeginEndIterator <string> iterator = new XMLBeginEndIterator <string>(new BufferedReader(new StringReader(NestingTestString)), "text", true, false, true); CompareResults(iterator, "A<text>B</text>C", "A<text>B</text>C<text>D</text>E", "A<text>B</text>C<text>D<text/></text>E"); }
public virtual void TestNesting() { XMLBeginEndIterator <string> iterator = new XMLBeginEndIterator <string>(new BufferedReader(new StringReader(NestingTestString)), "text", false, false, true); CompareResults(iterator, "ABC", "ABCDE", "ABCDE"); }
public virtual void TestSingleTags() { XMLBeginEndIterator <string> iterator = new XMLBeginEndIterator <string>(new BufferedReader(new StringReader(SingleTagTestString)), "text"); CompareResults(iterator, "This tests the xml input with single tags, which should not close the input"); }
public virtual void TestEmpty() { XMLBeginEndIterator <string> iterator = new XMLBeginEndIterator <string>(new BufferedReader(new StringReader(EmptyTestString)), "text"); CompareResults(iterator, string.Empty); }
public virtual void TestFound() { XMLBeginEndIterator <string> iterator = new XMLBeginEndIterator <string>(new BufferedReader(new StringReader(TestString)), "text"); CompareResults(iterator, "\n This tests the xml input.\n ", "\n This should be found.\n ", "\n The dog's barking kept the\n neighbors up all night.\n "); }
public virtual void TestNotFound() { XMLBeginEndIterator <string> iterator = new XMLBeginEndIterator <string>(new BufferedReader(new StringReader(TestString)), "zzzz"); CompareResults(iterator); }
public virtual void TestTwoTags() { XMLBeginEndIterator <string> iterator = new XMLBeginEndIterator <string>(new BufferedReader(new StringReader(TwoTagsString)), "foo|bar"); CompareResults(iterator, "This is the first sentence", "The dog's barking kept the neighbors up all night", "The owner could not stop the dog from barking"); }
public virtual void TestTagInText() { XMLBeginEndIterator <string> iterator = new XMLBeginEndIterator <string>(new BufferedReader(new StringReader(TagInTextString)), "bar"); CompareResults(iterator, "The dog's barking kept the neighbors up all night"); }
public virtual void TestContainingTags() { XMLBeginEndIterator <string> iterator = new XMLBeginEndIterator <string>(new BufferedReader(new StringReader(NestingTestString)), "text", true, true, true); CompareResults(iterator, "<text>A<text>B</text>C</text>", "<text>A<text>B</text>C<text>D</text>E</text>", "<text>A<text>B</text>C<text>D<text/></text>E</text>"); }