• R/O
  • SSH
  • HTTPS

qrobosdk: コミット


コミットメタ情報

リビジョン1818 (tree)
日時2010-05-09 23:31:02
作者satofumi

ログメッセージ

add test for rubi_parse.cpp

変更サマリ

差分

--- trunk/libs/input/rubi_parse.h (revision 1817)
+++ trunk/libs/input/rubi_parse.h (revision 1818)
@@ -10,18 +10,23 @@
1010 $Id$
1111 */
1212
13+#include <vector>
14+#include <cstddef>
15+
16+
1317 namespace qrk
1418 {
1519 typedef struct
1620 {
1721 size_t original_first;
18- size_t original_last;
22+ size_t original_size;
1923 size_t rubi_first;
20- size_t rubi_last;
24+ size_t rubi_size;
2125 } rubi_t;
2226
2327
24- extern void parse_rubi(std::vector<rubi_t>& rubi_positions);
28+ extern void parse_rubi(std::vector<rubi_t>& rubi_positions,
29+ const char* original, const char* kana);
2530 }
2631
2732 #endif /* !QRK_RUBI_PARSE_H */
--- trunk/libs/input/TestRubiParse.h (nonexistent)
+++ trunk/libs/input/TestRubiParse.h (revision 1818)
@@ -0,0 +1,26 @@
1+#ifndef TEST_RUBI_PARSE_H
2+#define TEST_RUBI_PARSE_H
3+
4+/*!
5+ \file
6+ \brief convertToJp.cpp のテスト
7+
8+ \author Satofumi KAMIMURA
9+
10+ $Id$
11+*/
12+
13+#include <cppunit/extensions/HelperMacros.h>
14+
15+
16+class TestRubiParse : public CppUnit::TestFixture
17+{
18+ CPPUNIT_TEST_SUITE(TestRubiParse);
19+ CPPUNIT_TEST(rubiParseTest);
20+ CPPUNIT_TEST_SUITE_END();
21+
22+public:
23+ void rubiParseTest(void);
24+};
25+
26+#endif /* !TEST_RUBI_PARSE_H */
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
--- trunk/libs/input/TestConvertToJp.h (revision 1817)
+++ trunk/libs/input/TestConvertToJp.h (revision 1818)
@@ -14,7 +14,6 @@
1414 */
1515
1616 #include <cppunit/extensions/HelperMacros.h>
17-#include "TestConvertToJp.h"
1817
1918
2019 class TestConvertToJp : public CppUnit::TestFixture
--- trunk/libs/input/rubi_parse.cpp (revision 1817)
+++ trunk/libs/input/rubi_parse.cpp (revision 1818)
@@ -10,8 +10,13 @@
1010 #include "rubi_parse.h"
1111
1212
13-void qrk::parse_rubi(std::vector<rubi_t>& rubi_positions)
13+void qrk::parse_rubi(std::vector<rubi_t>& rubi_positions,
14+ const char* original, const char* kana)
1415 {
15- (void)rubi_positions;
16+ (void)original;
17+ (void)kana;
18+
19+ rubi_positions.clear();
20+
1621 // !!!
1722 }
--- trunk/libs/input/Makefile (revision 1817)
+++ trunk/libs/input/Makefile (revision 1818)
@@ -43,7 +43,7 @@
4343 allTest.o : ../../unittest/allTest.cpp
4444 $(CXX) $(CXXFLAGS) `cppunit-config --cflags` $< -c -o $@
4545
46-TEST_OBJS = allTest.o TestConvertToRoman.o convertToRoman.o TestConvertToJp.o convertToJp.o TestUtf8.o Utf8.o
46+TEST_OBJS = allTest.o TestConvertToRoman.o convertToRoman.o TestConvertToJp.o convertToJp.o TestUtf8.o Utf8.o TestRubiParse.o rubi_parse.o
4747 allTest : $(TEST_OBJS)
4848 $(CXX) $(CXXFLAGS) $(TEST_OBJS) -o $@ `cppunit-config --libs` $(TEST_LDLIBS)
4949
--- trunk/libs/input/TestRubiParse.cpp (nonexistent)
+++ trunk/libs/input/TestRubiParse.cpp (revision 1818)
@@ -0,0 +1,65 @@
1+/*!
2+ \file
3+ \brief RubiParse.cpp のテスト
4+
5+ \author Satofumi KAMIMURA
6+
7+ $Id$
8+*/
9+
10+#include "TestRubiParse.h"
11+#include "rubi_parse.h"
12+
13+using namespace qrk;
14+using namespace std;
15+
16+CPPUNIT_TEST_SUITE_REGISTRATION(TestRubiParse);
17+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(TestRubiParse, "TestRubiParse");
18+
19+
20+void TestRubiParse::rubiParseTest(void)
21+{
22+ vector<rubi_t> rubi;
23+
24+ parse_rubi(rubi, "む", "む");
25+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rubi.size());
26+
27+ parse_rubi(rubi, "無", "む");
28+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rubi.size());
29+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rubi[0].original_first);
30+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rubi[0].original_size);
31+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rubi[0].rubi_first);
32+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rubi[0].rubi_size);
33+
34+ parse_rubi(rubi, "無し", "なし");
35+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rubi.size());
36+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rubi[0].original_first);
37+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rubi[0].original_size);
38+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rubi[0].rubi_first);
39+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rubi[0].rubi_size);
40+
41+ parse_rubi(rubi, "よい水", "よいみず");
42+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rubi.size());
43+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rubi[0].original_first);
44+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rubi[0].original_size);
45+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rubi[0].rubi_first);
46+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rubi[0].rubi_size);
47+
48+ parse_rubi(rubi, "よい水だ", "よいみずだ");
49+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rubi.size());
50+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rubi[0].original_first);
51+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rubi[0].original_size);
52+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rubi[0].rubi_first);
53+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rubi[0].rubi_size);
54+
55+ parse_rubi(rubi, "秋の田の", "あきのたの");
56+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rubi.size());
57+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rubi[0].original_first);
58+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rubi[0].original_size);
59+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rubi[0].rubi_first);
60+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rubi[0].rubi_size);
61+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rubi[1].original_first);
62+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rubi[1].original_size);
63+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), rubi[1].rubi_first);
64+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rubi[1].rubi_size);
65+}
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
旧リポジトリブラウザで表示