Sha256: 4bac870ef4776547b57e46f11e8250dac38bad351256706c5f624a696f1a8e17
Contents?: true
Size: 1.87 KB
Versions: 1
Compression:
Stored size: 1.87 KB
Contents
require "#{File.dirname(__FILE__)}/../lib/zidian" require "test/unit" class TestZidian < Test::Unit::TestCase def test_get_word_from_id word = Zidian.find(200) assert_equal(["aside", "to the side of"], word.english) assert_equal("一旁", word.simplified) end def test_get_words_from_ids words = Zidian.find([200, 210]) assert_equal(["aside", "to the side of"], words.first.english) assert_equal(["a moment, a while", "in a moment"], words.last.english) end def test_raise_invalid_id assert_raise(Zidian::InvalidIdException) do Zidian.find(25) end assert_raise(Zidian::InvalidIdException) do Zidian.find(86618) end end def test_find_word_from_string words = Zidian.find("shanghai") assert_equal("guai3", words.last.pinyin) end def test_find_word_from_pinyin words = Zidian.find("wei cheng") assert_equal("围城", words.first.simplified) end def test_find_word_from_pinyin_marked words = Zidian.find("wei2 cheng2") assert_equal("siege", words.first.english.first) end def test_raise_when_invalid_input_type assert_raise(Zidian::InvalFindInputException) do Zidian.find(:shanghai) end end def test_word_proper_extraction word = Zidian::Word.new("134:一夫當關,萬夫莫開 一夫当关,万夫莫开 [yi1 fu1 dang1 guan1 , wan4 fu1 mo4 kai1] /If one man holds the pass, ten thousand cannot pass (idiom); One man can hold the pass against ten thousand enemies/\n") assert_equal(134, word.id) assert_equal("一夫當關,萬夫莫開", word.traditional) assert_equal("一夫当关,万夫莫开", word.simplified) assert_equal("yi1 fu1 dang1 guan1 , wan4 fu1 mo4 kai1", word.pinyin) assert_equal(["If one man holds the pass, ten thousand cannot pass (idiom); One man can hold the pass against ten thousand enemies"], word.english) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zidian-0.2.0 | test/test_zidian.rb |