abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r611858 - /incubator/abdera/java/trunk/dependencies/i18n/src/test/java/org/apache/abdera/i18n/test/iri/TestLang.java
Date Mon, 14 Jan 2008 17:12:03 GMT
Author: jmsnell
Date: Mon Jan 14 09:11:45 2008
New Revision: 611858

URL: http://svn.apache.org/viewvc?rev=611858&view=rev
Log:
New test cases covering the rfc4646 lang impl

Modified:
    incubator/abdera/java/trunk/dependencies/i18n/src/test/java/org/apache/abdera/i18n/test/iri/TestLang.java

Modified: incubator/abdera/java/trunk/dependencies/i18n/src/test/java/org/apache/abdera/i18n/test/iri/TestLang.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/dependencies/i18n/src/test/java/org/apache/abdera/i18n/test/iri/TestLang.java?rev=611858&r1=611857&r2=611858&view=diff
==============================================================================
--- incubator/abdera/java/trunk/dependencies/i18n/src/test/java/org/apache/abdera/i18n/test/iri/TestLang.java
(original)
+++ incubator/abdera/java/trunk/dependencies/i18n/src/test/java/org/apache/abdera/i18n/test/iri/TestLang.java
Mon Jan 14 09:11:45 2008
@@ -19,16 +19,18 @@
 
 import java.util.Locale;
 
-import org.apache.abdera.i18n.lang.InvalidLangTagSyntax;
-import org.apache.abdera.i18n.lang.Lang;
-
 import junit.framework.TestCase;
 
+import org.apache.abdera.i18n.rfc4646.Lang;
+import org.apache.abdera.i18n.rfc4646.Range;
+
 public class TestLang extends TestCase {
 
+  @SuppressWarnings("deprecation") 
   public static void testLang() throws Exception {
     
-    Lang lang = new Lang("en-US-ca");
+    org.apache.abdera.i18n.lang.Lang lang = 
+      new org.apache.abdera.i18n.lang.Lang("en-US-ca");
     Locale testLocale = new Locale("en", "US", "ca");
         
     assertEquals(lang.getPrimary(),"en");
@@ -52,11 +54,46 @@
     
     Exception e = null;
     try {
-      lang = new Lang("en_US");
-    } catch (InvalidLangTagSyntax ex) {
+      lang = new org.apache.abdera.i18n.lang.Lang("en_US");
+    } catch (org.apache.abdera.i18n.lang.InvalidLangTagSyntax ex) {
       e = ex;
     }
     assertNotNull(e);
   }
   
+  public static void test4646Lang() throws Exception {
+    Lang lang = new Lang("en-Latn-US-valencia");
+    assertEquals(lang.getLanguage().toString(),"en");
+    assertEquals(lang.getRegion().toString(), "US");
+    assertEquals(lang.getScript().toString(), "Latn");
+    assertEquals(lang.getVariant().toString(), "valencia");
+    assertNull(lang.getExtLang());
+    assertNull(lang.getExtension());
+    assertNull(lang.getPrivateUse());
+    assertTrue(lang.isValid());
+    Locale locale = lang.getLocale();
+    assertEquals(locale.getCountry(),"US");
+    assertEquals(locale.getLanguage(),"en");
+    assertEquals(locale.getVariant(),"valencia");
+  }
+  
+  public static void test4647Matching() throws Exception {
+    Lang lang = new Lang("en-Latn-US-valencia");
+    Range range1 = new Range("*",true);
+    Range range2 = new Range("en-*",true);
+    Range range3 = new Range("en-Latn-*",true);
+    Range range4 = new Range("en-US-*",true);
+    Range range5 = new Range("en-*-US-*",true);
+    Range range6 = new Range("*-US",true);
+    Range range7 = new Range("*-valencia",true);
+    Range range8 = new Range("*-FR",true);
+    assertTrue(range1.matches(lang,true));
+    assertTrue(range2.matches(lang,true));
+    assertTrue(range3.matches(lang,true));
+    assertTrue(range4.matches(lang,true));
+    assertTrue(range5.matches(lang,true));
+    assertTrue(range6.matches(lang,true));
+    assertTrue(range7.matches(lang,true));
+    assertFalse(range8.matches(lang,true));
+  }
 }



Mime
View raw message