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]

FYI: few tests update.


Committed.

2006-11-23  Mario Torre  <neugens@nirvana.limasoftware.net>

	* gnu/testlet/java/text/DecimalFormat/formatToCharacterIterator.java
(test): 
	Code reformatted, added test for Format.Field attributes.
	* gnu/testlet/java/text/DecimalFormat/formatExp.java (test):
	New tests.
	* gnu/testlet/java/text/DecimalFormat/applyPattern.java (test): 
	fix broken test, plus explicity set the locale for the test.
	*
gnu/testlet/javax/swing/text/InternationalFormatter/InternationalFormatterTest.java:
	fix test tag, moved to 1.4.


-- 
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/formatExp.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/text/DecimalFormat/formatExp.java,v
retrieving revision 1.3
diff -u -r1.3 formatExp.java
--- gnu/testlet/java/text/DecimalFormat/formatExp.java	22 Sep 2006 20:28:38 -0000	1.3
+++ gnu/testlet/java/text/DecimalFormat/formatExp.java	23 Nov 2006 12:10:06 -0000
@@ -70,6 +70,9 @@
       apply (harness, df, "##.###E0");
       harness.check (df.format (12345), "1.2345E4");
 
+      apply (harness, df, "##.###E0");
+      harness.check (df.format (12346), "1.2346E4");
+      
       apply (harness, df, "00.###E0");
       harness.check (df.format (12345), "12.345E3");
       harness.check (df.format (1234), "12.34E2");
Index: gnu/testlet/java/text/DecimalFormat/applyPattern.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/text/DecimalFormat/applyPattern.java,v
retrieving revision 1.3
diff -u -r1.3 applyPattern.java
--- gnu/testlet/java/text/DecimalFormat/applyPattern.java	10 Oct 2006 22:36:48 -0000	1.3
+++ gnu/testlet/java/text/DecimalFormat/applyPattern.java	23 Nov 2006 12:10:06 -0000
@@ -25,6 +25,7 @@
 import gnu.testlet.Testlet;
 
 import java.text.DecimalFormat;
+import java.util.Locale;
 
 /**
  * Some checks for the applyPattern() method in the {@link DecimalFormat} class.
@@ -39,6 +40,9 @@
    */
   public void test(TestHarness harness) 
   {
+    Locale orig = Locale.getDefault();
+    Locale.setDefault(Locale.US);
+    
     DecimalFormat f1 = new DecimalFormat();
     
     // negativePrefix
@@ -80,7 +84,7 @@
     
     harness.checkPoint("null pattern");
     f1.applyPattern("");
-    harness.check(f1.format(123456789.123456789), "123.456.789,12345679");
+    harness.check(f1.format(123456789.123456789), "123,456,789.12345679");
     
     harness.checkPoint("invalid pattern");
     // try null argument
@@ -107,6 +111,7 @@
     }
     harness.check(pass);
     
+    Locale.setDefault(orig);
   }
 
 }
Index: gnu/testlet/java/text/DecimalFormat/formatToCharacterIterator.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/text/DecimalFormat/formatToCharacterIterator.java,v
retrieving revision 1.1
diff -u -r1.1 formatToCharacterIterator.java
--- gnu/testlet/java/text/DecimalFormat/formatToCharacterIterator.java	13 Mar 2005 20:42:07 -0000	1.1
+++ gnu/testlet/java/text/DecimalFormat/formatToCharacterIterator.java	23 Nov 2006 12:10:06 -0000
@@ -19,52 +19,87 @@
 // the Free Software Foundation, 59 Temple Place - Suite 330,
 // Boston, MA 02111-1307, USA.  */
 
+
 package gnu.testlet.java.text.DecimalFormat;
 
 import gnu.testlet.TestHarness;
 import gnu.testlet.Testlet;
 
+import java.text.AttributedCharacterIterator;
 import java.text.DecimalFormat;
+import java.text.NumberFormat.Field;
+import java.util.Iterator;
+import java.util.Set;
 
 /**
- * Some checks for the formatToCharacterIterator() method in the 
+ * Some checks for the formatToCharacterIterator() method in the
  * {@link DecimalFormat} class.
  */
-public class formatToCharacterIterator implements Testlet 
+public class formatToCharacterIterator
+    implements Testlet
 {
 
   /**
    * Runs the test using the specified harness.
    * 
-   * @param harness  the test harness (<code>null</code> not permitted).
+   * @param harness the test harness (<code>null</code> not permitted).
    */
-  public void test(TestHarness harness)  
+  public void test(TestHarness harness)
   {
     DecimalFormat f1 = new DecimalFormat();
-    
+
     // check null argument
     boolean pass = false;
     try
-    {
-      f1.formatToCharacterIterator(null);   
-    }
+      {
+        f1.formatToCharacterIterator(null);
+      }
     catch (NullPointerException e)
-    {
-      pass = true;   
-    }
+      {
+        pass = true;
+      }
     harness.check(pass);
-    
+
     // check non-numeric argument
     pass = false;
     try
-    {
-      f1.formatToCharacterIterator("Not a number");   
-    }
+      {
+        f1.formatToCharacterIterator("Not a number");
+      }
     catch (IllegalArgumentException e)
-    {
-      pass = true;   
-    }
+      {
+        pass = true;
+      }
     harness.check(pass);
+    
+    harness.checkPoint("Check for attributes after a valid parse");
+    
+    DecimalFormat f2 = new DecimalFormat("0.##;-0.##");
+    
+    // result is "-1234.56"
+    AttributedCharacterIterator chIter =
+      f2.formatToCharacterIterator(Double.valueOf(-1234.56));
+    
+    Set _keys = chIter.getAllAttributeKeys();
+    
+    // It seems that we don't get always the same order in the results
+    // but the values need to be the ones written later.
+    // This test should be completed checking even the start/end of each field
+    boolean pass1 = false;
+    boolean pass2 = false;
+    boolean pass3 = false;
+    boolean pass4 = false;
+    
+    for (Iterator i = _keys.iterator(); i.hasNext();)
+      {
+        //harness.debug("field: " + i.next());
+        Field field = (Field) i.next();
+        if (field.equals(Field.INTEGER)) pass1 = true;
+        if (field.equals(Field.FRACTION)) pass2 = true;
+        if (field.equals(Field.DECIMAL_SEPARATOR)) pass3 = true;
+        if (field.equals(Field.SIGN)) pass4 = true;
+      }
+    
+    harness.check(pass1 && pass2 && pass3 && pass4);
   }
-
 }

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