lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r901809 - in /lucene/java/trunk/src/test/org/apache/lucene/util: ArrayUtilTest.java TestArrayUtil.java
Date Thu, 21 Jan 2010 18:12:17 GMT
Author: mikemccand
Date: Thu Jan 21 18:12:16 2010
New Revision: 901809

URL: http://svn.apache.org/viewvc?rev=901809&view=rev
Log:
LUCENE-2213: consolidate ArrayUtil's 2 tests

Removed:
    lucene/java/trunk/src/test/org/apache/lucene/util/ArrayUtilTest.java
Modified:
    lucene/java/trunk/src/test/org/apache/lucene/util/TestArrayUtil.java

Modified: lucene/java/trunk/src/test/org/apache/lucene/util/TestArrayUtil.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/util/TestArrayUtil.java?rev=901809&r1=901808&r2=901809&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/util/TestArrayUtil.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/util/TestArrayUtil.java Thu Jan 21 18:12:16
2010
@@ -56,4 +56,50 @@
       assertTrue(v >= minTargetSize);
     }
   }
+
+  public void testParseInt() throws Exception {
+    int test;
+    try {
+      test = ArrayUtil.parseInt("".toCharArray());
+      assertTrue(false);
+    } catch (NumberFormatException e) {
+      //expected
+    }
+    try {
+      test = ArrayUtil.parseInt("foo".toCharArray());
+      assertTrue(false);
+    } catch (NumberFormatException e) {
+      //expected
+    }
+    try {
+      test = ArrayUtil.parseInt(String.valueOf(Long.MAX_VALUE).toCharArray());
+      assertTrue(false);
+    } catch (NumberFormatException e) {
+      //expected
+    }
+    try {
+      test = ArrayUtil.parseInt("0.34".toCharArray());
+      assertTrue(false);
+    } catch (NumberFormatException e) {
+      //expected
+    }
+
+    try {
+      test = ArrayUtil.parseInt("1".toCharArray());
+      assertTrue(test + " does not equal: " + 1, test == 1);
+      test = ArrayUtil.parseInt("-10000".toCharArray());
+      assertTrue(test + " does not equal: " + -10000, test == -10000);
+      test = ArrayUtil.parseInt("1923".toCharArray());
+      assertTrue(test + " does not equal: " + 1923, test == 1923);
+      test = ArrayUtil.parseInt("-1".toCharArray());
+      assertTrue(test + " does not equal: " + -1, test == -1);
+      test = ArrayUtil.parseInt("foo 1923 bar".toCharArray(), 4, 4);
+      assertTrue(test + " does not equal: " + 1923, test == 1923);
+    } catch (NumberFormatException e) {
+      e.printStackTrace();
+      assertTrue(false);
+    }
+
+  }
+
 }



Mime
View raw message