public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* FIY: new tests for DecimalFormat
@ 2006-07-27 23:23 Mario Torre
  0 siblings, 0 replies; only message in thread
From: Mario Torre @ 2006-07-27 23:23 UTC (permalink / raw)
  To: mauve-patches

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

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/

[-- Attachment #2: mauve_decimal_format.patch --]
[-- Type: text/x-patch, Size: 1860 bytes --]

### 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);
+  }
 }

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

only message in thread, other threads:[~2006-07-27 23:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-27 23:23 FIY: new tests for DecimalFormat Mario Torre

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).