Clean up static fields after the suite is over. Cleaned up generics too.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1387044 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dawid Weiss 2012-09-18 08:30:56 +00:00
parent 562f150e17
commit fa9182cfb6

View File

@ -20,6 +20,7 @@ package org.apache.solr.util;
import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.util.NumberUtils; import org.apache.solr.util.NumberUtils;
import org.apache.solr.util.BCDUtils; import org.apache.solr.util.BCDUtils;
import org.junit.AfterClass;
import org.junit.Assert; import org.junit.Assert;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@ -36,10 +37,9 @@ public class TestNumberUtils extends LuceneTestCase {
rng = random(); rng = random();
} }
private static String arrstr(char[] arr, int start, int end) { @AfterClass
String str="["; public static void cleanup() {
for (int i=start; i<end; i++) str += arr[i]+"("+(int)arr[i]+"),"; rng = null;
return str+"]";
} }
static int[] special = {0,10,100,1000,10000,Integer.MAX_VALUE, Integer.MIN_VALUE}; static int[] special = {0,10,100,1000,10000,Integer.MAX_VALUE, Integer.MIN_VALUE};
@ -84,8 +84,7 @@ public class TestNumberUtils extends LuceneTestCase {
return dspecial[((int)j&0x7fffffff) % dspecial.length]* ((i & 0x20)==0?1:-1) + ((i&0x03)-1); return dspecial[((int)j&0x7fffffff) % dspecial.length]* ((i & 0x20)==0?1:-1) + ((i&0x03)-1);
} }
public static <T extends Comparable<T>> void test(T n1, T n2, Converter conv) {
public static void test(Comparable n1, Comparable n2, Converter conv) {
String s1=n1.toString(); String s1=n1.toString();
String s2=n2.toString(); String s2=n2.toString();
String v1 = conv.toInternal(s1); String v1 = conv.toInternal(s1);
@ -125,8 +124,6 @@ public class TestNumberUtils extends LuceneTestCase {
public void testConverters() public void testConverters()
{ {
int iter=1000; int iter=1000;
int arrsz=100000;
int num=12345;
// INTEGERS // INTEGERS
List<Converter> converters = new ArrayList<Converter>(); List<Converter> converters = new ArrayList<Converter>();
@ -137,9 +134,7 @@ public class TestNumberUtils extends LuceneTestCase {
for( Converter c : converters ) { for( Converter c : converters ) {
for (int i=0; i<iter; i++) { for (int i=0; i<iter; i++) {
Comparable n1 = getSpecial(); test(getSpecial(), getSpecial(), c );
Comparable n2 = getSpecial();
test( n1, n2, c );
} }
} }
@ -150,9 +145,7 @@ public class TestNumberUtils extends LuceneTestCase {
converters.add( new Base100S() ); converters.add( new Base100S() );
for( Converter c : converters ) { for( Converter c : converters ) {
for (int i=0; i<iter; i++) { for (int i=0; i<iter; i++) {
Comparable n1 = getLongSpecial(); test(getLongSpecial(), getLongSpecial(), c );
Comparable n2 = getLongSpecial();
test( n1, n2, c );
} }
} }
@ -162,9 +155,7 @@ public class TestNumberUtils extends LuceneTestCase {
converters.add( new SortFloat() ); converters.add( new SortFloat() );
for( Converter c : converters ) { for( Converter c : converters ) {
for (int i=0; i<iter; i++) { for (int i=0; i<iter; i++) {
Comparable n1 = getFloatSpecial(); test(getFloatSpecial(), getFloatSpecial(), c );
Comparable n2 = getFloatSpecial();
test( n1, n2, c );
} }
} }
@ -173,9 +164,7 @@ public class TestNumberUtils extends LuceneTestCase {
converters.add( new SortDouble() ); converters.add( new SortDouble() );
for( Converter c : converters ) { for( Converter c : converters ) {
for (int i=0; i<iter; i++) { for (int i=0; i<iter; i++) {
Comparable n1 = getDoubleSpecial(); test(getDoubleSpecial(), getDoubleSpecial(), c );
Comparable n2 = getDoubleSpecial();
test( n1, n2, c );
} }
} }
} }