You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2013/01/17 13:09:12 UTC

svn commit: r1434634 - in /lucene/dev/trunk/lucene/facet/src: java/org/apache/lucene/facet/taxonomy/CategoryPath.java test/org/apache/lucene/facet/taxonomy/TestCategoryPath.java

Author: shaie
Date: Thu Jan 17 12:09:11 2013
New Revision: 1434634

URL: http://svn.apache.org/viewvc?rev=1434634&view=rev
Log:
fix bug in CategoryPath.compareTo

Modified:
    lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java
    lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCategoryPath.java

Modified: lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java?rev=1434634&r1=1434633&r2=1434634&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java (original)
+++ lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java Thu Jan 17 12:09:11 2013
@@ -92,8 +92,8 @@ public class CategoryPath implements Com
    */
   @Override
   public int compareTo(CategoryPath other) {
-    int length = this.length < other.length ? this.length : other.length;
-    for (int i = 0, j = 0; i < length; i++, j++) {
+    final int len = length < other.length ? length : other.length;
+    for (int i = 0, j = 0; i < len; i++, j++) {
       int cmp = components[i].compareTo(other.components[j]);
       if (cmp < 0) return -1; // this is 'before'
       if (cmp > 0) return 1; // this is 'after'

Modified: lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCategoryPath.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCategoryPath.java?rev=1434634&r1=1434633&r2=1434634&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCategoryPath.java (original)
+++ lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCategoryPath.java Thu Jan 17 12:09:11 2013
@@ -163,16 +163,22 @@ public class TestCategoryPath extends Lu
     CategoryPath p = new CategoryPath("a/b/c/d", '/');
     CategoryPath pother = new CategoryPath("a/b/c/d", '/');
     assertEquals(0, pother.compareTo(p));
+    assertEquals(0, p.compareTo(pother));
     pother = new CategoryPath("", '/');
     assertTrue(pother.compareTo(p) < 0);
+    assertTrue(p.compareTo(pother) > 0);
     pother = new CategoryPath("a/b_/c/d", '/');
     assertTrue(pother.compareTo(p) > 0);
+    assertTrue(p.compareTo(pother) < 0);
     pother = new CategoryPath("a/b/c", '/');
     assertTrue(pother.compareTo(p) < 0);
+    assertTrue(p.compareTo(pother) > 0);
     pother = new CategoryPath("a/b/c/e", '/');
     assertTrue(pother.compareTo(p) > 0);
+    assertTrue(p.compareTo(pother) < 0);
     pother = new CategoryPath("a/b/c//e", '/');
     assertTrue(pother.compareTo(p) < 0);
+    assertTrue(p.compareTo(pother) > 0);
   }
 
 }