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 updates


Few updates for DecimalFormat plus some starting tests for Collator.

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

	* gnu/testlet/java/text/RuleBasedCollator/CollatorTests.java
(basicCompare):
	New class.
	(orderComparision): New Test
	(test): Default entry for tests.
	* gnu/testlet/java/text/RuleBasedCollator/VeryBasic.java (test):
	Removed debug output.
	* gnu/testlet/java/text/DecimalFormat/format.java (testLocale):
	Added tests case for locale other than US.
-- 
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.15
diff -u -r1.15 format.java
--- gnu/testlet/java/text/DecimalFormat/format.java	1 Dec 2006 22:59:27 -0000	1.15
+++ gnu/testlet/java/text/DecimalFormat/format.java	7 Dec 2006 16:25:55 -0000
@@ -375,26 +375,26 @@
   
   private void testLocale(TestHarness harness)
   {
-	  // just two tests, other are in gnu.testlet.locales.LocaleTest
-	  
-	  harness.checkPoint("locale: GERMANY");
-	  
-	  // by default, calls DecimalFormat
-	  java.text.NumberFormat nf
-	  	= java.text.NumberFormat.getCurrencyInstance(Locale.GERMANY);
-	      
-	  harness.check(nf.format(5000.25), "5.000,25 â");
-	  
-	  harness.checkPoint("locale: ITALY");
-	  
-	  nf = java.text.NumberFormat.getCurrencyInstance(Locale.ITALY);
-	  harness.check(nf.format(5000.25), "â 5.000,25");
-	  
-	  java.text.DecimalFormatSymbols symbols
-	  	= ((DecimalFormat)nf).getDecimalFormatSymbols();
-	  
-	  harness.check(',', symbols.getDecimalSeparator());
-	  harness.check(',', symbols.getMonetaryDecimalSeparator());
-	  harness.check('.', symbols.getGroupingSeparator());
+    // just two tests, other are in gnu.testlet.locales.LocaleTest
+    
+    harness.checkPoint("locale: GERMANY");
+    
+    // by default, calls DecimalFormat
+    java.text.NumberFormat nf
+      = java.text.NumberFormat.getCurrencyInstance(Locale.GERMANY);
+    
+    harness.check(nf.format(5000.25), "5.000,25 â");
+    
+    harness.checkPoint("locale: ITALY");
+      
+    nf = java.text.NumberFormat.getCurrencyInstance(Locale.ITALY);
+    harness.check(nf.format(5000.25), "â 5.000,25");
+	  
+    java.text.DecimalFormatSymbols symbols
+      = ((DecimalFormat)nf).getDecimalFormatSymbols();
+    
+    harness.check(',', symbols.getDecimalSeparator());
+    harness.check(',', symbols.getMonetaryDecimalSeparator());
+    harness.check('.', symbols.getGroupingSeparator());
   }
 }
Index: gnu/testlet/java/text/RuleBasedCollator/VeryBasic.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/text/RuleBasedCollator/VeryBasic.java,v
retrieving revision 1.3
diff -u -r1.3 VeryBasic.java
--- gnu/testlet/java/text/RuleBasedCollator/VeryBasic.java	8 Jul 2003 15:56:30 -0000	1.3
+++ gnu/testlet/java/text/RuleBasedCollator/VeryBasic.java	7 Dec 2006 16:25:55 -0000
@@ -37,7 +37,6 @@
     // for good ol' English
     Collator col = Collator.getInstance(Locale.US);
     
-    harness.debug("foo bar" + col.compare("foo", "bar"));
     harness.check(col.compare("foo", "bar") > 0, "foo and bar");
     harness.check(col.compare("bar", "baz") < 0, "bar and baz");
     harness.check(col.compare("FOO", "FOO") == 0, "FOO and FOO");
Index: gnu/testlet/java/text/RuleBasedCollator/CollatorTests.java
===================================================================
RCS file: gnu/testlet/java/text/RuleBasedCollator/CollatorTests.java
diff -N gnu/testlet/java/text/RuleBasedCollator/CollatorTests.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/text/RuleBasedCollator/CollatorTests.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,119 @@
+/* CollatorTests.java -- Contain various tests for the Collator and
+   RuleBasedCollator class.
+   
+   Copyright (C) 2006 Mario Torre <neugens@limasoftware.net>
+   
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.java.text.RuleBasedCollator;
+
+import java.text.CollationElementIterator;
+import java.text.Collator;
+import java.text.ParseException;
+import java.text.RuleBasedCollator;
+import java.util.Locale;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * @author Mario Torre <neugens@limasoftware.net>
+ */
+public class CollatorTests implements Testlet
+{
+  private TestHarness harness = null;
+  
+  /* (non-Javadoc)
+   * @see gnu.testlet.Testlet#test(gnu.testlet.TestHarness)
+   */
+  public void test(TestHarness harness)
+  {
+    // TODO Auto-generated method stub
+    this.harness = harness;
+    
+    basicCompare();
+    orderComparision();
+  }
+  
+  private void basicCompare()
+  {
+    // test taken from the JDK Javadoc
+    // Compare two strings in the default locale
+    Collator myCollator = Collator.getInstance(Locale.US);
+    
+    this.harness.check((myCollator.compare("abc", "ABC") < 0),
+                       "basic comparision");
+    
+    myCollator.setStrength(Collator.PRIMARY);
+    this.harness.check((myCollator.compare("abc", "ABC") == 0),
+                       "equivalent strings");
+    
+    String SimpleRule = "< a< b< c< d";
+    
+    boolean pass = false;
+    try
+      {
+        RuleBasedCollator simpleRuleCollator =
+          new RuleBasedCollator(SimpleRule);
+        
+        pass = (simpleRuleCollator.compare("abc", "ABC") < 0);
+      }
+    catch (ParseException e)
+      {
+        pass = false;
+      }
+    
+    this.harness.check(pass, "simple rule test");
+  }
+  
+  private void orderComparision()
+  {
+    RuleBasedCollator c = (RuleBasedCollator)Collator.getInstance(Locale.US);
+    CollationElementIterator iter = c.getCollationElementIterator("Foo");
+
+    // given by the 1.5.0 jdk
+    int [][] results = 
+      {
+       {5767169, 88, 0, 1},
+       {6356992, 97, 0, 0},
+       {6356992, 97, 0, 0}
+      };
+    
+    int element;
+    int i = 0;
+    while ((element = iter.next()) != CollationElementIterator.NULLORDER)
+      {
+        
+        int primary = CollationElementIterator.primaryOrder(element);
+        int secondary = CollationElementIterator.secondaryOrder(element);
+        int tertiary = CollationElementIterator.tertiaryOrder(element);
+        
+        this.harness.check((results[i][0] == element), "element #" + i);
+        
+        this.harness.check((results[i][1] == primary), "primary #" + i);
+        this.harness.check((results[i][2] == secondary), "secondary #" + i);
+        this.harness.check((results[i][3] == tertiary), "tertiary #" + i);
+        
+        i++;
+      }
+  }
+}

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