You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2011/02/24 01:23:39 UTC
svn commit: r1073996 - in /lucene/dev/branches/branch_3x: ./ lucene/
lucene/src/test/org/apache/lucene/util/TestSmallFloat.java solr/
Author: yonik
Date: Thu Feb 24 00:23:39 2011
New Revision: 1073996
URL: http://svn.apache.org/viewvc?rev=1073996&view=rev
Log:
tests: add a few more floatToByte constant tests
Modified:
lucene/dev/branches/branch_3x/ (props changed)
lucene/dev/branches/branch_3x/lucene/ (props changed)
lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestSmallFloat.java
lucene/dev/branches/branch_3x/solr/ (props changed)
Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestSmallFloat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestSmallFloat.java?rev=1073996&r1=1073995&r2=1073996&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestSmallFloat.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/TestSmallFloat.java Thu Feb 24 00:23:39 2011
@@ -81,12 +81,6 @@ public class TestSmallFloat extends Luce
public void testByteToFloat() {
- assertEquals(0, orig_floatToByte_v13(5.8123817E-10f)); // verify the old bug (see LUCENE-2937)
- assertEquals(1, orig_floatToByte(5.8123817E-10f)); // verify it's fixed in this test code
- assertEquals(1, SmallFloat.floatToByte315(5.8123817E-10f)); // verify it's fixed
-
- assertEquals(1, orig_floatToByte(Float.MIN_VALUE));
-
for (int i=0; i<256; i++) {
float f1 = orig_byteToFloat((byte)i);
float f2 = SmallFloat.byteToFloat((byte)i, 3,15);
@@ -101,6 +95,22 @@ public class TestSmallFloat extends Luce
}
public void testFloatToByte() {
+ assertEquals(0, orig_floatToByte_v13(5.8123817E-10f)); // verify the old bug (see LUCENE-2937)
+ assertEquals(1, orig_floatToByte(5.8123817E-10f)); // verify it's fixed in this test code
+ assertEquals(1, SmallFloat.floatToByte315(5.8123817E-10f)); // verify it's fixed
+
+ // test some constants
+ assertEquals(0, SmallFloat.floatToByte315(0));
+ assertEquals(1, SmallFloat.floatToByte315(Float.MIN_VALUE)); // underflow rounds up to smallest positive
+ assertEquals(255, SmallFloat.floatToByte315(Float.MAX_VALUE) & 0xff); // overflow rounds down to largest positive
+ assertEquals(255, SmallFloat.floatToByte315(Float.POSITIVE_INFINITY) & 0xff);
+
+ // all negatives map to 0
+ assertEquals(0, SmallFloat.floatToByte315(-Float.MIN_VALUE));
+ assertEquals(0, SmallFloat.floatToByte315(-Float.MAX_VALUE));
+ assertEquals(0, SmallFloat.floatToByte315(Float.NEGATIVE_INFINITY));
+
+
// up iterations for more exhaustive test after changing something
int num = 100000 * RANDOM_MULTIPLIER;
for (int i = 0; i < num; i++) {