Exemplo n.º 1
0
        public void testToGwoyeuRomatzyhStringArray()
        {
            // any input of non-Chinese characters will return null
            {
                Assert.IsNull(PinyinHelper.toGwoyeuRomatzyhStringArray('A'));
                Assert.IsNull(PinyinHelper.toGwoyeuRomatzyhStringArray('z'));
                Assert.IsNull(PinyinHelper.toGwoyeuRomatzyhStringArray(','));
                Assert.IsNull(PinyinHelper.toGwoyeuRomatzyhStringArray('。'));
            }

            // Chinese characters
            // single pronounciation
            {
                String[] expectedPinyinArray = new String[] { "lii" };
                String[] pinyinArray         = PinyinHelper.toGwoyeuRomatzyhStringArray('李');

                Assert.AreEqual(expectedPinyinArray.Length, pinyinArray.Length);

                for (int i = 0; i < expectedPinyinArray.Length; i++)
                {
                    Assert.AreEqual(expectedPinyinArray[i], pinyinArray[i]);
                }
            }
            {
                String[] expectedPinyinArray = new String[] { "chyou" };
                String[] pinyinArray         = PinyinHelper.toGwoyeuRomatzyhStringArray('球');

                Assert.AreEqual(expectedPinyinArray.Length, pinyinArray.Length);

                for (int i = 0; i < expectedPinyinArray.Length; i++)
                {
                    Assert.AreEqual(expectedPinyinArray[i], pinyinArray[i]);
                }
            }
            {
                String[] expectedPinyinArray = new String[] { "juang" };
                String[] pinyinArray         = PinyinHelper.toGwoyeuRomatzyhStringArray('桩');

                Assert.AreEqual(expectedPinyinArray.Length, pinyinArray.Length);

                for (int i = 0; i < expectedPinyinArray.Length; i++)
                {
                    Assert.AreEqual(expectedPinyinArray[i], pinyinArray[i]);
                }
            }

            {
                String[] expectedPinyinArray = new String[] { "fuh" };
                String[] pinyinArray         = PinyinHelper.toGwoyeuRomatzyhStringArray('付');

                Assert.AreEqual(expectedPinyinArray.Length, pinyinArray.Length);

                for (int i = 0; i < expectedPinyinArray.Length; i++)
                {
                    Assert.AreEqual(expectedPinyinArray[i], pinyinArray[i]);
                }
            }

            // multiple pronounciations
            {
                String[] expectedPinyinArray = new String[] { "chwan", "juann" };
                String[] pinyinArray         = PinyinHelper.toGwoyeuRomatzyhStringArray('传');

                Assert.AreEqual(expectedPinyinArray.Length, pinyinArray.Length);

                for (int i = 0; i < expectedPinyinArray.Length; i++)
                {
                    Assert.AreEqual(expectedPinyinArray[i], pinyinArray[i]);
                }
            }

            {
                String[] expectedPinyinArray = new String[] { ".me", ".mha", "iau" };
                String[] pinyinArray         = PinyinHelper.toGwoyeuRomatzyhStringArray('么');

                Assert.AreEqual(expectedPinyinArray.Length, pinyinArray.Length);

                for (int i = 0; i < expectedPinyinArray.Length; i++)
                {
                    Assert.AreEqual(expectedPinyinArray[i], pinyinArray[i]);
                }
            }

            {
                String[] expectedPinyinArray = new String[] { "liuh", "luh" };
                String[] pinyinArray         = PinyinHelper.toGwoyeuRomatzyhStringArray('绿');

                Assert.AreEqual(expectedPinyinArray.Length, pinyinArray.Length);

                for (int i = 0; i < expectedPinyinArray.Length; i++)
                {
                    Assert.AreEqual(expectedPinyinArray[i], pinyinArray[i]);
                }
            }
        }