Kouhei Sutou
kous****@users*****
2006年 11月 27日 (月) 15:46:41 JST
Index: tomoe/test/Makefile.am diff -u tomoe/test/Makefile.am:1.16 tomoe/test/Makefile.am:1.17 --- tomoe/test/Makefile.am:1.16 Sun Nov 26 16:30:37 2006 +++ tomoe/test/Makefile.am Mon Nov 27 15:46:41 2006 @@ -26,6 +26,7 @@ run-spec.rb \ run-test.sh \ tomoe-spec-utils.rb \ + char_spec.rb \ context_spec.rb \ dict_spec.rb \ writing_spec.rb Index: tomoe/test/char_spec.rb diff -u /dev/null tomoe/test/char_spec.rb:1.1 --- /dev/null Mon Nov 27 15:46:41 2006 +++ tomoe/test/char_spec.rb Mon Nov 27 15:46:41 2006 @@ -0,0 +1,17 @@ +require 'tomoe-spec-utils' + +context "Tomoe::Char" do + specify "should not dump any XML without data" do + @char = Tomoe::Char.new + @char.to_xml.should_empty + end + + specify "should dump XML with code-point" do + @char = Tomoe::Char.new + @char.code = "ã" + xml = " <character>\n" + xml << " <code-point>ã</code-point>\n" + xml << " </character>\n" + @char.to_xml.should == xml + end +end Index: tomoe/test/context_spec.rb diff -u tomoe/test/context_spec.rb:1.11 tomoe/test/context_spec.rb:1.12 --- tomoe/test/context_spec.rb:1.11 Mon Nov 27 14:21:31 2006 +++ tomoe/test/context_spec.rb Mon Nov 27 15:46:41 2006 @@ -1,11 +1,13 @@ require 'tomoe-spec-utils' context "Tomoe::Context" do - setup do - @context = Tomoe::Context.new - test_dir = File.expand_path(File.join(File.dirname(__FILE__))) - @context.load_config(@config_file.path) - @context.load_recognizer(recognizer_dir, "simple") + @@context = nil + def context + return @@context if @@context + @@context = Tomoe::Context.new + @@context.load_config(@config_file.path) + @@context.load_recognizer(recognizer_dir, "simple") + @@context end def numbers_to_point(str) @@ -38,7 +40,7 @@ end query = Tomoe::Query.new query.writing = writing - cands =****@conte*****(query) + cands = context.search(query) [base, cands.collect {|cand| cand.character.code}].should == expected end @@ -47,7 +49,7 @@ specify "Search by reading" do query = Tomoe::Query.new query.add_reading(Tomoe::Reading.new(Tomoe::READING_KUN, "ãã")) - cands =****@conte*****(query) + cands = context.search(query) cands.collect {|cand| cand.character.code}.should == ["è", "è", "æ±"] end end