mirror of https://github.com/apache/lucene.git
LUCENE-1901: Add a test (also to Token.java)
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@812690 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c3063ec882
commit
8f67ba4811
|
@ -150,6 +150,21 @@ public class TestToken extends LuceneTestCase {
|
||||||
assertEquals("(hi there,0,5)", t.toString());
|
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 {
|
public void testMixedStringArray() throws Exception {
|
||||||
Token t = new Token("hello", 0, 5);
|
Token t = new Token("hello", 0, 5);
|
||||||
assertEquals(t.termText(), "hello");
|
assertEquals(t.termText(), "hello");
|
||||||
|
|
|
@ -146,6 +146,21 @@ public class TestTermAttributeImpl extends LuceneTestCase {
|
||||||
assertNotSame(buf, copy.termBuffer());
|
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 {
|
public void testCopyTo() throws Exception {
|
||||||
TermAttributeImpl t = new TermAttributeImpl();
|
TermAttributeImpl t = new TermAttributeImpl();
|
||||||
TermAttributeImpl copy = (TermAttributeImpl) TestSimpleAttributeImpls.assertCopyIsEqual(t);
|
TermAttributeImpl copy = (TermAttributeImpl) TestSimpleAttributeImpls.assertCopyIsEqual(t);
|
||||||
|
|
Loading…
Reference in New Issue