public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* FYI: Arrays.binarySearch tests
@ 2007-01-03 20:57 Francis Kung
  0 siblings, 0 replies; only message in thread
From: Francis Kung @ 2007-01-03 20:57 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 412 bytes --]

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.

[-- Attachment #2: mauve-binarysearch.diff --]
[-- Type: text/x-patch, Size: 2278 bytes --]

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 {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-01-03 20:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-03 20:57 FYI: Arrays.binarySearch tests Francis Kung

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).