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]

FIY: new tests for DecimalFormat


These tests, committed, are used to check some combination of the
setMaximumIntegerDigits and setMaximumFractionDigits parameters in
DecimalFormat.

The goal of these tests is to have compatibility with the RI, though
I have to admit that sometimes the RI does weird things...

The test should fail on the current classpath, but not on the
implementation I'm currently working on.

2006-07-28  Mario Torre  <neugens@limasoftware.net>

	* gnu/testlet/java/text/DecimalFormat/format.java (test): Added new
	test 'testMaximumDigits'.
	(testMaximumDigits): New test for some configuration of
	setMaximumIntegerDigits and setMaximumFractionDigits.

-- 
Lima Software, SO.PR.IND. s.r.l.
http://www.limasoftware.net/
pgp key: http://subkeys.pgp.net/

Please, support open standards:
http://opendocumentfellowship.org/petition/
http://www.nosoftwarepatents.com/
### Eclipse Workspace Patch 1.0
#P mauve
Index: gnu/testlet/java/text/DecimalFormat/format.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/text/DecimalFormat/format.java,v
retrieving revision 1.11
diff -u -r1.11 format.java
--- gnu/testlet/java/text/DecimalFormat/format.java	24 Jul 2006 00:58:51 -0000	1.11
+++ gnu/testlet/java/text/DecimalFormat/format.java	27 Jul 2006 23:16:40 -0000
@@ -42,6 +42,7 @@
     testBigInteger(harness);
     testNaN(harness);
     testInfinity(harness);
+    testMaximumDigits(harness);
   }
 
   public void apply(TestHarness harness, DecimalFormat df, String pattern)
@@ -279,4 +280,47 @@
     
     Locale.setDefault(orig);
   }
+  
+  private void testMaximumDigits(TestHarness harness)
+  {
+    Locale orig = Locale.getDefault();
+    Locale.setDefault(Locale.US);
+    
+    harness.checkPoint("testMaxAndMinDigits");
+
+    double number = 123456789.987654321;
+    
+    DecimalFormat df = new DecimalFormat();
+    
+    df.setGroupingUsed(false);
+    df.setGroupingSize(3);
+    
+    df.setMaximumIntegerDigits(2);
+    df.setMaximumFractionDigits(4);
+          
+    // NaN does not have prefixes and suffixes
+    harness.check(df.format(number), "89.9877");
+    
+    df.setMaximumIntegerDigits(5);
+    df.setMaximumFractionDigits(0);
+
+    harness.check(df.format(number), "56790");
+    
+    df.setMaximumIntegerDigits(0);
+    df.setMaximumFractionDigits(5);
+
+    harness.check(df.format(number), ".98765");
+    
+    df.setMaximumIntegerDigits(-1);
+    df.setMaximumFractionDigits(-1);
+    
+    harness.check(df.format(number), "0");
+    
+    df.setMaximumIntegerDigits(390);
+    df.setMaximumFractionDigits(340);
+    
+    harness.check(df.format(number), "123456789.98765433");
+    
+    Locale.setDefault(orig);
+  }
 }

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