add new codesys support
[chise/ruby.git] / t / tc_char.rb
index 20c9032..c3bc828 100755 (executable)
@@ -9,12 +9,11 @@ include CHISE
 class TC_Character < Test::Unit::TestCase
   def setup() @char = Character.get("字") end #UTF8で与えること
   def test_char(char)
-#    assert_equal(23383, char.char_id, "translate to char_id")
 #    assert_equal(6, char.get_char_attribute('total_strokes'), "get total strokes by XEmacs UTF-2000 like method")
     assert_equal(6, char['total_strokes'], "get total strokes by Hash like method") if char.is_a? Character
     assert_equal(6, char.total_strokes, "get total strokes by method")
     assert_equal(23383, char.ucs, "translate to ucs")
-    assert_equal(22358, char.chinese_gb2312, "get character code in chinese GB2312")
+    assert_equal(22358, char.gb2312, "get character code in chinese GB2312")
     assert_equal(1777, char.shinjigen_2, "get shinjigen 2")
     assert_equal(3, char.ideographic_strokes, "get")
     assert_equal(39, char.ideographic_radical, "get")
@@ -42,17 +41,17 @@ class TC_Character < Test::Unit::TestCase
     assert_instance_of(String, @char.inspect)
   end
   def test_er
-    assert_equal(Character.get("&J90-3B7A;"), @char, "jisx0208")
+    assert_equal(@char, Character.get("&J90-3B7A;"), "jisx0208") #まだ継承関係を実装していない。
 #    assert_equal("&J90-3B7A;", @char.to_er, "jisx0208")
-    assert_equal(Character.get("&MCS-00005B57;"), @char, "mcs")
-    assert_equal(Character.get("&M-06942;"), @char, "ideograph-daikanwa, Morohashi")
+    assert_equal(@char, Character.get("&MCS-00005B57;"), "mcs")
+    assert_equal(@char, Character.get("&M-06942;"), "ideograph-daikanwa, Morohashi")
   end
   def test_latin
     char = Character.get("A")
-    assert_equal(char.ascii, 65, "ascii")
+    assert_equal(65, char.ascii, "ascii")
     assert_equal(char.bidi_category, "L", "bidi")
     assert_equal(char.name, "LATIN CAPITAL LETTER A", "name")
-    assert_equal(char.ucs, 65, "ucs")
+    assert_equal(65, char.ucs, "ucs")
     assert_equal(char.latin_jisx0201, 65, "jisx0201")
     assert_equal(char.latin_viscii, 65, "viscii") #って何?
 #->fullwidth: (((name . "FULLWIDTH LATIN CAPITAL LETTER A") (ucs . 65313)))
@@ -62,7 +61,7 @@ class TC_Character < Test::Unit::TestCase
   end
   def test_ids
     char = Character.get("⿰")
-    assert_equal(char.name, "IDEOGRAPHIC DESCRIPTION CHARACTER LEFT TO RIGHT", "ids name")
+    assert_equal("IDEOGRAPHIC DESCRIPTION CHARACTER LEFT TO RIGHT", char.name, "ids name")
     #assert_equal(char.to_er, "&U+2FF0;", "ids er")
     assert_equal(char.to_er, "&#x2ff0;", "ids er")
     assert_equal(char.bidi_category, "ON", "ids bidi")
@@ -119,8 +118,8 @@ class TC_Character < Test::Unit::TestCase
     assert_equal(0x5B57, "字".ucs)
     assert_equal(0x5B57, @char.ucs)
 
-    assert_equal(0xfa55, "突".char['=>ucs-jis'])
-    assert_equal(0xfa55, "突".map_ucs_jis)
+    assert_equal(0xfa55, "突".char['=>ucs@jis'])
+    assert_equal(0xfa55, "突".map_ucs_at_jis)
 
     char1 = Character.get("23383")
     char2 = Character.get(23383)
@@ -130,10 +129,10 @@ class TC_Character < Test::Unit::TestCase
     char2 = Character.get(2)
     assert_not_equal(char1, char2)
 
-    assert_equal("(((name . \"FULLWIDTH DIGIT ONE\") (ucs . 65297)))", "1".char['->fullwidth'])
-    assert_equal("(((name . \"FULLWIDTH DIGIT ONE\") (ucs . 65297)))", "1".char.to_fullwidth)
-    assert_equal("(((name . \"DIGIT ONE\") (ucs . 49)))", "1".char['<-fullwidth'])
-    assert_equal("(((name . \"DIGIT ONE\") (ucs . 49)))", "1".char.from_fullwidth)
+    assert_equal("(((name . \"FULLWIDTH DIGIT ONE\") (=ucs . 65297)))", "1".char['->fullwidth'])
+    assert_equal("(((name . \"FULLWIDTH DIGIT ONE\") (=ucs . 65297)))", "1".char.to_fullwidth)
+    assert_equal("(((name . \"DIGIT ONE\") (=ucs . 49)))", "1".char['<-fullwidth'])
+    assert_equal("(((name . \"DIGIT ONE\") (=ucs . 49)))", "1".char.from_fullwidth)
   end
   def teardown() @char = nil  end
 end