Commits

Lars Yencken committed 6903b6e

Fixed a bug in the handling of the N kana in alignment, and added a test.

  • Participants
  • Parent commits 24a9377

Comments (0)

Files changed (2)

File src/scripts.cpp

 {
     unsigned int len = 0;
     for (wstring::const_iterator c = s.begin(); c != s.end(); c++) {
-        if (!isSmallKana(*c)) {
+        if (!isSmallKana(*c) && *c != L'ん') {
             len++;
         }
     }

File src/tests/testGenerator.hpp

     Segment* m_unique;
     Segment* m_basic;
     Segment* m_smallKana;
+    Segment* m_nKana;
     Segment* m_longVowel;
     Segment* m_mixed;
 
     {
         m_unique = new Segment(L"私", L"わたし");
         m_basic = new Segment(L"漢字", L"たんだん"); 
-        m_smallKana = new Segment(L"発起人", L"ほっきにん");
+        m_smallKana = new Segment(L"発起", L"ほっき");
+        m_nKana = new Segment(L"発起人", L"ほきにん");
         m_longVowel = new Segment(L"ビール", L"ビール");
         m_mixed = new Segment(L"此の節", L"このせつ");
     }
             }
         }
     }
+    
+    void testNKana()
+    {
+        vector<Alignment> alignments;
+        potentialAlignments(*m_nKana, alignments);
+        CPPUNIT_ASSERT(alignments.size() == 4);
+        for (unsigned int i = 0; i < alignments.size(); i++) {
+            Alignment& a = alignments[i];
+            for (Alignment::iterator iter = a.begin(); iter != a.end();
+                    iter++) {
+                CPPUNIT_ASSERT(iter->g.size() == bigKanaLen(iter->p));
+            }
+        }
+    }
 
     void testLongVowel()
     {
                     &GeneratorTest::testBasic));
         s->addTest(new CppUnit::TestCaller<GeneratorTest>("testSmallKana",
                     &GeneratorTest::testSmallKana));
+        s->addTest(new CppUnit::TestCaller<GeneratorTest>("testNKana",
+                    &GeneratorTest::testNKana));
         s->addTest(new CppUnit::TestCaller<GeneratorTest>("testLongVowel",
                     &GeneratorTest::testLongVowel));
         s->addTest(new CppUnit::TestCaller<GeneratorTest>("testMixedScript",