diff --git a/lib/string_to_pinyin.rb b/lib/string_to_pinyin.rb index 56e7734..65f7546 100644 --- a/lib/string_to_pinyin.rb +++ b/lib/string_to_pinyin.rb @@ -13,7 +13,7 @@ def to_pinyin if h[char] result = result + h[char] + " " else - result = result + self + " " + result = result + char end end return result.rstrip diff --git a/spec/string_to_pinyin_spec.rb b/spec/string_to_pinyin_spec.rb index 3117442..4ac4676 100644 --- a/spec/string_to_pinyin_spec.rb +++ b/spec/string_to_pinyin_spec.rb @@ -6,6 +6,7 @@ @single_char = "名" @multiple_chars = "中华人民共和国" @nil_char = "a" + @punctuated = "你好! 你是中国人吗? <- that was mandarin" end it "should return pinyin for a single character if found" do @@ -19,4 +20,8 @@ it "should return a character if its not found in the index" do @nil_char.to_pinyin.should == 'a' end + + it "should return 'non-simplified chinese characters' as they are" do + @punctuated.to_pinyin.should == 'nĭ hăo ! nĭ shì zhōng guó rén ma ? <- that was mandarin' + end end