2 # Copyright (C) 2002-2004 Kouichirou Eto, All rights reserved.
6 class TestCharacter < Test::Unit::TestCase
8 c1 = "字".char # flyweight pattern
9 c2 = CHISE::Character.get("?字")
10 assert_equal(c1, c2) # equal
11 assert_same(c1, c2) # same instance
12 c3 = CHISE::Character.new(0x5b57)
13 assert_not_equal(c1, c3) # not equal
14 assert_not_same(c1, c3) # not same instance
15 assert_equal(c1.char_id, c3.char_id)
20 assert_equal(23383, char["=ucs"])
21 assert_equal(23383, char["ucs"])
22 assert_equal(23383, char.ucs)
23 assert_equal(22358, char.gb2312)
24 assert_equal(6, char.total_strokes)
25 assert_equal(3, char.ideographic_strokes)
26 assert_equal(39, char.ideographic_radical)
27 assert_equal(nil, char.nosuchfeature)
28 assert_raise(RuntimeError){ char.nosuchmethod(0) }
33 assert_equal(65, char.ascii)
34 assert_equal(65, char.ucs)
35 assert_equal(65, char.latin_jisx0201)
36 assert_equal(65, char.latin_viscii)
37 assert_equal("L", char.bidi_category)
38 assert_equal("LATIN CAPITAL LETTER A", char.name)
42 #assert_equal("&J90-3B7A;", "字".char.to_er)
43 assert_equal("字", "字".char.to_er)
44 assert_equal("字", "&M-06942;".de_er.char.to_er)
45 assert_equal("𡙫", "&M-06000;".de_er.char.to_er)
49 assert_equal("DIGIT ONE", "1".name)
50 assert_equal("DIGIT ONE", "1".char.name)
51 assert_equal("DIGIT ONE", "1".char["name"])
52 assert_equal("(((name . \"FULLWIDTH DIGIT ONE\") (=ucs . 65297)))", "1".char["->fullwidth"])
53 assert_equal("(((name . \"FULLWIDTH DIGIT ONE\") (=ucs . 65297)))", "1".to_fullwidth)
54 assert_equal("(((name . \"DIGIT ONE\") (=ucs . 49)))", "1".char["<-fullwidth"])
55 assert_equal("(((name . \"DIGIT ONE\") (=ucs . 49)))", "1".from_fullwidth)
56 # assert_equal(0xfa55, "突".map_ucs_at_jis)
57 # assert_equal(0xfa55, "突".char["=>ucs@jis"])
62 char["test_attribute"] = "test"
63 assert_equal("test", char.test_attribute)
64 char["test_attribute"] = "test2"
65 assert_equal("test2", char.test_attribute)