You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by ry...@apache.org on 2008/06/06 21:07:04 UTC

svn commit: r664083 - /lucene/solr/trunk/src/test/org/apache/solr/util/TestUtils.java

Author: ryan
Date: Fri Jun  6 12:07:04 2008
New Revision: 664083

URL: http://svn.apache.org/viewvc?rev=664083&view=rev
Log:
adding tests for ntz

Modified:
    lucene/solr/trunk/src/test/org/apache/solr/util/TestUtils.java

Modified: lucene/solr/trunk/src/test/org/apache/solr/util/TestUtils.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/util/TestUtils.java?rev=664083&r1=664082&r2=664083&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/util/TestUtils.java (original)
+++ lucene/solr/trunk/src/test/org/apache/solr/util/TestUtils.java Fri Jun  6 12:07:04 2008
@@ -122,4 +122,23 @@
     assertEquals( num, NumberUtils.SortableStr2long(sortable, 0, sortable.length() ) );
     assertEquals( Long.toString(num), NumberUtils.SortableStr2long(sortable) );
   }
+  
+  public void testBitUtils()
+  {
+    long num = 100000;
+    assertEquals( 5, BitUtil.ntz(num) );
+    assertEquals( 5, BitUtil.ntz2(num) );
+    assertEquals( 5, BitUtil.ntz3(num) );
+    
+    num = 10;
+    assertEquals( 1, BitUtil.ntz(num) );
+    assertEquals( 1, BitUtil.ntz2(num) );
+    assertEquals( 1, BitUtil.ntz3(num) );
+
+    num = 234;
+   //?????  why 1?
+   // assertEquals( 0, BitUtil.ntz(num) );
+   // assertEquals( 0, BitUtil.ntz2(num) );
+   // assertEquals( 0, BitUtil.ntz3(num) );
+  }
 }



Re: svn commit: r664083 - /lucene/solr/trunk/src/test/org/apache/solr/util/TestUtils.java

Posted by Yonik Seeley <yo...@apache.org>.
On Fri, Jun 6, 2008 at 3:10 PM, Ryan McKinley <ry...@gmail.com> wrote:
>>
>> +    num = 234;
>> +   //?????  why 1?
>> +   // assertEquals( 0, BitUtil.ntz(num) );
>> +   // assertEquals( 0, BitUtil.ntz2(num) );
>> +   // assertEquals( 0, BitUtil.ntz3(num) );
>> +  }
>
> Any idea why the answer is 1?  the docs say "(only works for x!=0)"

ntz is for binary bits (the other test cases just happen to be the
same in binary and decimal - pretty funny).
Anyway 234 in binary is 11101010  (1 trailing zero)


-Yonik

Re: svn commit: r664083 - /lucene/solr/trunk/src/test/org/apache/solr/util/TestUtils.java

Posted by Ryan McKinley <ry...@gmail.com>.
>
> +    num = 234;
> +   //?????  why 1?
> +   // assertEquals( 0, BitUtil.ntz(num) );
> +   // assertEquals( 0, BitUtil.ntz2(num) );
> +   // assertEquals( 0, BitUtil.ntz3(num) );
> +  }

Any idea why the answer is 1?  the docs say "(only works for x!=0)"