This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: Arrays.binarySearch tests


Hi,

This patch adds some checks to the binarySearch methods for the empty-array case.

Cheers,
Francis


2007-01-03 Francis Kung <fkung@redhat.com>


	* gnu/testlet/java/util/Arrays/binarySearch.java:
	(testByte): Added check for empty array.
	(testChar): Likewise.
	(testDouble): Likewise.
	(testFloat): Likewise.
	(testInt): Likewise.
	(testLong): Likewise.
	(testObject): Likewise.
	(testShort): Likewise.
Index: gnu/testlet/java/util/Arrays/binarySearch.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/util/Arrays/binarySearch.java,v
retrieving revision 1.1
diff -u -r1.1 binarySearch.java
--- gnu/testlet/java/util/Arrays/binarySearch.java	27 Aug 2004 21:57:50 -0000	1.1
+++ gnu/testlet/java/util/Arrays/binarySearch.java	3 Jan 2007 20:55:37 -0000
@@ -69,6 +69,9 @@
       pass = true;
     }
     harness.check(pass);
+    
+    b1 = new byte[0];
+    harness.check(Arrays.binarySearch(b1, (byte)0), -1);
   }
 
   private void testChar(TestHarness harness)
@@ -91,6 +94,9 @@
       pass = true;
     }
     harness.check(pass);
+    
+    b1 = new char[0];
+    harness.check(Arrays.binarySearch(b1, '0'), -1);
   }
 
   private void testDouble(TestHarness harness)
@@ -113,6 +119,9 @@
       pass = true;
     }
     harness.check(pass);
+    
+    b1 = new double[0];
+    harness.check(Arrays.binarySearch(b1, 0.0), -1);
   }
 
   private void testFloat(TestHarness harness)
@@ -135,6 +144,9 @@
       pass = true;
     }
     harness.check(pass);
+
+    b1 = new float[0];
+    harness.check(Arrays.binarySearch(b1, 0.0f), -1);
   }
 
   private void testInt(TestHarness harness)
@@ -157,6 +169,9 @@
       pass = true;
     }
     harness.check(pass);
+
+    b1 = new int[0];
+    harness.check(Arrays.binarySearch(b1, 0), -1);
   }
 
   private void testLong(TestHarness harness)
@@ -179,6 +194,9 @@
       pass = true;
     }
     harness.check(pass);
+
+    b1 = new long[0];
+    harness.check(Arrays.binarySearch(b1, 0), -1);
   }
 
   private void testObject(TestHarness harness)
@@ -227,6 +245,9 @@
     harness.check(Arrays.binarySearch(b1, "2", new ReverseComparator()) == 1);
     harness.check(Arrays.binarySearch(b1, "3", new ReverseComparator()) == 0);
     harness.check(Arrays.binarySearch(b1, "4", new ReverseComparator()) == -1);
+  
+    b1 = new Object[0];
+    harness.check(Arrays.binarySearch(b1, ""), -1);
   }
 
   private void testShort(TestHarness harness)
@@ -249,6 +270,9 @@
       pass = true;
     }
     harness.check(pass);
+
+    b1 = new short[0];
+    harness.check(Arrays.binarySearch(b1, (short)0), -1);
   }
 
   static class ReverseComparator implements Comparator {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]