* FYI: some new DecimalFormat tests
@ 2006-08-29 17:36 Mario Torre
0 siblings, 0 replies; only message in thread
From: Mario Torre @ 2006-08-29 17:36 UTC (permalink / raw)
To: mauve-patches
[-- Attachment #1: Type: text/plain, Size: 646 bytes --]
My work on classpath is going really slow these days, but at least I
found the time to add a couple more tests...
Ciao,
Mario
Changelog:
2006-08-29 Mario Torre <neugens@limasoftware.net>
* gnu/testlet/java/text/DecimalFormat/formatExp.java (test):
added new tests.
* gnu/testlet/java/text/DecimalFormat/parse.java (test):
added new tests.
* gnu/testlet/java/text/DecimalFormat/format.java (testGeneral):
added new tests.
--
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: decimal_format_mauve_2006_08_29.patch --]
[-- Type: text/x-patch, Size: 5617 bytes --]
### Eclipse Workspace Patch 1.0
#P mauve
Index: gnu/testlet/java/text/DecimalFormat/parse.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/text/DecimalFormat/parse.java,v
retrieving revision 1.10
diff -u -r1.10 parse.java
--- gnu/testlet/java/text/DecimalFormat/parse.java 21 Aug 2006 18:42:32 -0000 1.10
+++ gnu/testlet/java/text/DecimalFormat/parse.java 29 Aug 2006 17:27:08 -0000
@@ -69,6 +69,14 @@
harness.check (num instanceof Double);
harness.check (num.doubleValue(), -1234.56);
+ num = parseIt (df, "-0", pp);
+ harness.check (num instanceof Double);
+ harness.check (num.doubleValue(), -0.0);
+
+ num = parseIt (df, "-0.0", pp);
+ harness.check (num instanceof Double);
+ harness.check (num.doubleValue(), -0.0);
+
apply (harness, df, "0.#");
num = parseIt (df, "1234.6", pp);
harness.check (num instanceof Double);
@@ -96,6 +104,15 @@
harness.check (num instanceof Long);
harness.check (num.longValue (), 200000);
+ num = parseIt (df, "2.0000E-5", pp);
+ harness.check (num instanceof Double);
+ harness.check (num.doubleValue(), 2.0E-5);
+
+ // this one is tricky... -E5 is considered part of the suffix
+ num = parseIt (df, "2.000-E5", pp);
+ harness.check (num instanceof Long);
+ harness.check (num.doubleValue(), 2);
+
apply (harness, df, "0.000");
num = parseIt (df, "2.000", pp);
harness.check (num instanceof Long);
Index: gnu/testlet/java/text/DecimalFormat/format.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/text/DecimalFormat/format.java,v
retrieving revision 1.12
diff -u -r1.12 format.java
--- gnu/testlet/java/text/DecimalFormat/format.java 27 Jul 2006 23:23:20 -0000 1.12
+++ gnu/testlet/java/text/DecimalFormat/format.java 29 Aug 2006 17:27:08 -0000
@@ -87,7 +87,11 @@
df.setDecimalSeparatorAlwaysShown(true);
harness.check(df.format(- 1234.56), "-1235.");
harness.check(df.format(1234.56), "1235.");
-
+ harness.check(df.format(-1234567.890), "-123,4568.");
+
+ apply(harness, df, "#,###,###");
+ harness.check(df.format(-1234567.890), "-1,234,568");
+
apply(harness, df, "0");
harness.check(df.format(- 1234.56), "-1235");
harness.check(df.format(1234.56), "1235");
@@ -116,6 +120,38 @@
apply(harness, df, "'#'#.#");
harness.check(df.format(30), "#30");
+ apply(harness, df, "000000");
+ harness.check(df.format(-1234.567), "-001235");
+
+ apply(harness, df, "##");
+ harness.check(df.format(-1234.567), "-1235");
+
+ harness.check(df.format(0), "0");
+
+ apply(harness, df, "##00");
+ harness.check(df.format(0), "00");
+
+ apply(harness, df, ".00");
+ harness.check(df.format(-.567), "-.57");
+
+ apply(harness, df, "0.00");
+ harness.check(df.format(-.567), "-0.57");
+
+ apply(harness, df, ".######");
+ harness.check(df.format(-1234.567), "-1234.567");
+
+ apply(harness, df, "#.000000");
+ harness.check(df.format(-1234.567), "-1234.567000");
+
+ apply(harness, df, "'#'#");
+ harness.check(df.format(-1234.567), "-#1235");
+
+ apply(harness, df, "'abc'#");
+ harness.check(df.format(-1234.567), "-abc1235");
+
+ apply(harness, df, "'positive'#;'negative' -");
+ harness.check(df.format(-1234.567), "negative -1235");
+
// grouping size of zero might cause a failure - see bug parade 4088503
harness.checkPoint("regression tests for setGroupingSize");
df = new DecimalFormat();
@@ -123,7 +159,7 @@
harness.check(df.format(100000), "100000");
harness.check(df.isGroupingUsed());
harness.check(df.getGroupingSize(), 0);
-
+
// FIXME: we don't actually know the right result here, because
// neither the JCL book nor the JDK 1.2 docs explain what should
// happen. The below represents how I think things ought to
@@ -131,7 +167,6 @@
// idea. E.g., JDK1.1 prints "200000.0000E" in the first case.
// apply (harness, df, "0.0000E#");
// harness.check (df.format (200000), "2.0000E+5");
-
// apply (harness, df, "00.00E00");
// harness.check (df.format (200000), "20.00E+04");
}
Index: gnu/testlet/java/text/DecimalFormat/formatExp.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/text/DecimalFormat/formatExp.java,v
retrieving revision 1.1
diff -u -r1.1 formatExp.java
--- gnu/testlet/java/text/DecimalFormat/formatExp.java 7 Sep 2003 12:57:48 -0000 1.1
+++ gnu/testlet/java/text/DecimalFormat/formatExp.java 29 Aug 2006 17:27:08 -0000
@@ -73,5 +73,24 @@
apply (harness, df, "00.###E0");
harness.check (df.format (12345), "12.345E3");
harness.check (df.format (1234), "12.34E2");
+
+ apply(harness, df, "0E0");
+ harness.check(df.format(-1234.567), "-1E3");
+
+ apply(harness, df, "00E00");
+ harness.check(df.format(-1234.567), "-12E02");
+
+ apply(harness, df, "000E00");
+ harness.check(df.format(-1234.567), "-123E01");
+
+ apply(harness, df, "0000000000E0");
+ harness.check(df.format(-1234.567), "-1234567000E-6");
+
+ apply(harness, df, "0.0E0");
+ harness.check(df.format(-1234.567), "-1.2E3");
+
+ apply(harness, df, "00.00E0");
+ harness.check(df.format(-1234.567), "-12.35E2");
+ harness.check(df.format(-.1234567), "-12.35E-2");
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-08-29 17:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-29 17:36 FYI: some new DecimalFormat tests 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).