public void TestFilterWithMark() { TokenStream stream = new WhitespaceTokenizer(new StringReader( "Do have a nice day")); // 1-4 length string ReverseStringFilter filter = new ReverseStringFilter(stream, '\u0001'); ITermAttribute text = filter.GetAttribute<ITermAttribute>(); Assert.True(filter.IncrementToken()); Assert.AreEqual("\u0001oD", text.Term); Assert.True(filter.IncrementToken()); Assert.AreEqual("\u0001evah", text.Term); Assert.True(filter.IncrementToken()); Assert.AreEqual("\u0001a", text.Term); Assert.True(filter.IncrementToken()); Assert.AreEqual("\u0001ecin", text.Term); Assert.True(filter.IncrementToken()); Assert.AreEqual("\u0001yad", text.Term); Assert.False(filter.IncrementToken()); }
public void TestFilterWithMark() { TokenStream stream = new WhitespaceTokenizer(new StringReader( "Do have a nice day")); // 1-4 length string ReverseStringFilter filter = new ReverseStringFilter(stream, '\u0001'); ITermAttribute text = filter.GetAttribute <ITermAttribute>(); Assert.True(filter.IncrementToken()); Assert.AreEqual("\u0001oD", text.Term); Assert.True(filter.IncrementToken()); Assert.AreEqual("\u0001evah", text.Term); Assert.True(filter.IncrementToken()); Assert.AreEqual("\u0001a", text.Term); Assert.True(filter.IncrementToken()); Assert.AreEqual("\u0001ecin", text.Term); Assert.True(filter.IncrementToken()); Assert.AreEqual("\u0001yad", text.Term); Assert.False(filter.IncrementToken()); }
public void TestReverseChar() { char[] buffer = { 'A', 'B', 'C', 'D', 'E', 'F' }; ReverseStringFilter.Reverse(buffer, 2, 3); Assert.AreEqual("ABEDCF", new String(buffer)); }
public void TestReverseString() { Assert.AreEqual("A", ReverseStringFilter.Reverse("A")); Assert.AreEqual("BA", ReverseStringFilter.Reverse("AB")); Assert.AreEqual("CBA", ReverseStringFilter.Reverse("ABC")); }