CnCityDict extends PinyinMapDict { @Override public Map<String, String[]> mapping() { return mDict; } private  CnCityDict(); static CnCityDict getInstance(); @Override Map<String, String[]> mapping();  }
@Test public void words() throws Exception { Set<String> words = mDict.mapping().keySet(); assertThat(words.contains(null), is(false)); assertThat(words.size(), is(97)); }
@Test public void toPinyin() throws Exception { Set<String> words = mDict.mapping().keySet(); for (String word : words) { String[] pinyins = mDict.mapping().get(word); assertThat(word.length(), is(pinyins.length)); } }
@Test public void toPinyin_test_not_same_with_PinyinOrigin() throws Exception { Set<String> words = mDict.mapping().keySet(); for (String word : words) { String[] originPinyins = new String[word.length()]; for (int i = 0; i < word.length(); i++) { originPinyins[i] = Pinyin.toPinyin(word.charAt(i)); } String[] pinyins = mDict.mapping().get(word); boolean hasDifferent = false; for (int i = 0; i < word.length(); i++) { if (!originPinyins[i].equalsIgnoreCase(pinyins[i])) { hasDifferent = true; break; } } assertThat(hasDifferent, is(true)); } }
@Test public void test_pinyin_only_contains_letters() throws Exception { Set<String> words = mDict.mapping().keySet(); for (String word : words) { String[] pinyins = mDict.mapping().get(word); for (String pinyin : pinyins) { assertThat(pinyin.matches("[a-zA-Z]+"), is(true)); } } }