xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r628273 [3/3] - in /xmlgraphics/commons/trunk: ./ src/java/org/apache/xmlgraphics/fonts/ src/resources/org/apache/xmlgraphics/fonts/ test/java/org/apache/xmlgraphics/fonts/
Date Sat, 16 Feb 2008 11:58:36 GMT
Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/fonts/GlyphsTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/fonts/GlyphsTest.java?rev=628273&r1=628272&r2=628273&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/fonts/GlyphsTest.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/fonts/GlyphsTest.java Sat Feb
16 03:58:34 2008
@@ -26,23 +26,68 @@
  */
 public class GlyphsTest extends TestCase {
 
-    public void testGetUnicodeCodePointsForGlyphName() throws Exception {
+    public void testGetUnicodeSequenceForGlyphName() throws Exception {
         String glyph;
         String unicodes;
         
         glyph = "Omega";
-        unicodes = Glyphs.getUnicodeCodePointsForGlyphName(glyph);
-        assertEquals(2, unicodes.length());
-        assertTrue("Must contain 03A9 - GREEK CAPITAL LETTER OMEGA",
-                unicodes.indexOf("\u03A9") >= 0);
-        assertTrue("Must contain 2126 - OHM SIGN",
-                unicodes.indexOf("\u03A9") >= 0);
+        unicodes = Glyphs.getUnicodeSequenceForGlyphName(glyph);
+        assertEquals(1, unicodes.length());
+        assertEquals("Must contain 2126 - OHM SIGN",
+                unicodes.charAt(0), '\u2126');
+
+        glyph = "Omegagreek";
+        unicodes = Glyphs.getUnicodeSequenceForGlyphName(glyph);
+        assertEquals(1, unicodes.length());
+        assertEquals("Must contain 03A9 - GREEK CAPITAL LETTER OMEGA",
+                unicodes.charAt(0), '\u03A9');
 
         glyph = "A";
-        unicodes = Glyphs.getUnicodeCodePointsForGlyphName(glyph);
+        unicodes = Glyphs.getUnicodeSequenceForGlyphName(glyph);
         assertEquals(1, unicodes.length());
-        assertTrue("Must contain 0041 - LATIN CAPITAL LETTER A",
-                unicodes.indexOf("\u0041") >= 0);
+        assertEquals("Must contain 0041 - LATIN CAPITAL LETTER A",
+                unicodes.charAt(0), '\u0041');
+        
+        glyph = "rehyehaleflamarabic";
+        unicodes = Glyphs.getUnicodeSequenceForGlyphName(glyph);
+        assertEquals(4, unicodes.length());
+        assertEquals("Expected 0631 - ARABIC LETTER REH at position 0",
+                unicodes.charAt(0), '\u0631');
+        assertEquals("Expected FEF3 - ARABIC LETTER YEH INITAL FORM at position 1",
+                unicodes.charAt(1), '\uFEF3');
+        assertEquals("Expected FE8E - ARABIC LETTER ALEF FINAL FORM at position 2",
+                unicodes.charAt(2), '\uFE8E');
+        assertEquals("Expected 0644 - ARABIC LETTER LAM at position 3",
+                unicodes.charAt(3), '\u0644');
+        
+        glyph = "Lcommaaccent_uni20AC0308_u20AC";
+        unicodes = Glyphs.getUnicodeSequenceForGlyphName(glyph);
+        assertEquals(4, unicodes.length());
+        assertEquals("Must contain 013B",
+                unicodes.charAt(0), '\u013B');
+        assertEquals("Must contain 20AC",
+                unicodes.charAt(1), '\u20AC');
+        assertEquals("Must contain 0308",
+                unicodes.charAt(2), '\u0308');
+        assertEquals("Must contain 20AC",
+                unicodes.charAt(3), '\u20AC');
+        
+        glyph = "blah";
+        unicodes = Glyphs.getUnicodeSequenceForGlyphName(glyph);
+        assertNull(unicodes);
     }
     
+    public void testGetCharNameAlternativesFor() throws Exception {
+        String[] alts = Glyphs.getCharNameAlternativesFor("Omega");
+        assertEquals(1, alts.length);
+        assertEquals("Omegagreek", alts[0]);
+
+        alts = Glyphs.getCharNameAlternativesFor("nbspace");
+        assertEquals(2, alts.length);
+        assertEquals("space", alts[0]);
+        assertEquals("nonbreakingspace", alts[1]);
+
+        alts = Glyphs.getCharNameAlternativesFor("A");
+        assertNull(alts);
+    }
 }



---------------------------------------------------------------------
Apache XML Graphics Project URL: http://xmlgraphics.apache.org/
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org


Mime
View raw message