test/java/lang/ToString.java

Print this page

        

@@ -21,11 +21,11 @@
  * questions.
  */
 
 /*
  * @test
- * @bug 4031762
+ * @bug 4031762 8042990
  * @summary Test the primitive wrappers static toString()
  */
 
 import java.util.Random;
 

@@ -98,7 +98,24 @@
             Double D = new Double(d);
             if (!D.toString().equals(Double.toString(d)))
                 throw new RuntimeException("Double wrapper toString() failure.");
         }
 
+        // unsigned hex int
+        for(int x=0; x<100; x++) {
+            int i = generator.nextInt();
+            int w = 1 + generator.nextInt(9);
+            String s = String.format("%0" + w + "x", i);
+            if (!s.equals(Integer.toHexString(i, w)))
+                throw new RuntimeException("Integer wrapper toHexString() failed for " + i + ".");
+        }
+
+        // unsigned hex long
+        for(int x=0; x<100; x++) {
+            long l = generator.nextLong();
+            int w = 1 + generator.nextInt(19);
+            String s = String.format("%0" + w + "x", l);
+            if (!s.equals(Long.toHexString(l, w)))
+                throw new RuntimeException("Long wrapper toHexString() failed for " + l + ".");
+        }
     }
 }