You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by us...@apache.org on 2009/09/08 22:49:50 UTC
svn commit: r812690 - in
/lucene/java/trunk/src/test/org/apache/lucene/analysis: TestToken.java
tokenattributes/TestTermAttributeImpl.java
Author: uschindler
Date: Tue Sep 8 20:49:49 2009
New Revision: 812690
URL: http://svn.apache.org/viewvc?rev=812690&view=rev
Log:
LUCENE-1901: Add a test (also to Token.java)
Modified:
lucene/java/trunk/src/test/org/apache/lucene/analysis/TestToken.java
lucene/java/trunk/src/test/org/apache/lucene/analysis/tokenattributes/TestTermAttributeImpl.java
Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestToken.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestToken.java?rev=812690&r1=812689&r2=812690&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/TestToken.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/TestToken.java Tue Sep 8 20:49:49 2009
@@ -150,6 +150,21 @@
assertEquals("(hi there,0,5)", t.toString());
}
+ public void testTermBufferEquals() throws Exception {
+ Token t1a = new Token();
+ char[] content1a = "hello".toCharArray();
+ t1a.setTermBuffer(content1a, 0, 5);
+ Token t1b = new Token();
+ char[] content1b = "hello".toCharArray();
+ t1b.setTermBuffer(content1b, 0, 5);
+ Token t2 = new Token();
+ char[] content2 = "hello2".toCharArray();
+ t2.setTermBuffer(content2, 0, 6);
+ assertTrue(t1a.equals(t1b));
+ assertFalse(t1a.equals(t2));
+ assertFalse(t2.equals(t1b));
+ }
+
public void testMixedStringArray() throws Exception {
Token t = new Token("hello", 0, 5);
assertEquals(t.termText(), "hello");
Modified: lucene/java/trunk/src/test/org/apache/lucene/analysis/tokenattributes/TestTermAttributeImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/tokenattributes/TestTermAttributeImpl.java?rev=812690&r1=812689&r2=812690&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/analysis/tokenattributes/TestTermAttributeImpl.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/analysis/tokenattributes/TestTermAttributeImpl.java Tue Sep 8 20:49:49 2009
@@ -146,6 +146,21 @@
assertNotSame(buf, copy.termBuffer());
}
+ public void testEquals() throws Exception {
+ TermAttributeImpl t1a = new TermAttributeImpl();
+ char[] content1a = "hello".toCharArray();
+ t1a.setTermBuffer(content1a, 0, 5);
+ TermAttributeImpl t1b = new TermAttributeImpl();
+ char[] content1b = "hello".toCharArray();
+ t1b.setTermBuffer(content1b, 0, 5);
+ TermAttributeImpl t2 = new TermAttributeImpl();
+ char[] content2 = "hello2".toCharArray();
+ t2.setTermBuffer(content2, 0, 6);
+ assertTrue(t1a.equals(t1b));
+ assertFalse(t1a.equals(t2));
+ assertFalse(t2.equals(t1b));
+ }
+
public void testCopyTo() throws Exception {
TermAttributeImpl t = new TermAttributeImpl();
TermAttributeImpl copy = (TermAttributeImpl) TestSimpleAttributeImpls.assertCopyIsEqual(t);