Develop and Download Open Source Software

Browse Subversion Repository

Contents of /jpinput/TestJpTextConverter.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 279 - (show annotations) (download) (as text)
Wed Mar 12 05:28:19 2008 UTC (16 years, 1 month ago) by satofumi
File MIME type: text/x-c++src
File size: 3021 byte(s)
adjust tab index
1 /*!
2 \file
3 \brief ローマ字かな変換のテスト
4
5 \author Satofumi KAMIMURA
6
7 $Id$
8 */
9
10 #include "TestJpTextConverter.h"
11 #include "ArrayTestUtil.h"
12
13
14 CPPUNIT_TEST_SUITE_REGISTRATION(TestJpTextConverter);
15 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(TestJpTextConverter,
16 "TestJpTextConverter");
17
18 #if 0
19 // バッファの長さを返す
20 static int getBufferLength(Uint16 buffer[]) {
21 int length = 0;
22 while (buffer[length] != 0x00) {
23 ++length;
24 }
25 return length;
26 }
27 #endif
28
29
30 // 基本操作の動作確認
31 void TestJpTextConverter::bufferCtrlTest(void) {
32
33 CPPUNIT_FAIL("Not implemented.");
34
35 #if 0
36 RomanJpConverter cmv;
37 Uint16 *buffer = cmv.getConvertBuffer();
38
39 CPPUNIT_ASSERT_EQUAL(0, getBufferLength(buffer));
40
41 cmv.addChar('c');
42
43 CPPUNIT_ASSERT_EQUAL(1, getBufferLength(buffer));
44
45 cmv.addChar('b');
46 CPPUNIT_ASSERT_EQUAL(2, getBufferLength(buffer));
47
48 cmv.deleteLast();
49 CPPUNIT_ASSERT_EQUAL(1, getBufferLength(buffer));
50
51 cmv.deleteLast();
52 CPPUNIT_ASSERT_EQUAL(0, getBufferLength(buffer));
53
54 cmv.deleteLast();
55 CPPUNIT_ASSERT_EQUAL(0, getBufferLength(buffer));
56 #endif
57 }
58
59
60 // ローマ字変換のテスト
61 void TestJpTextConverter::romaConvertTest(void) {
62
63 CPPUNIT_FAIL("Not implemented.");
64
65 #if 0
66 Convert cmv;
67 Uint16 expected[CONVERT_BUFFER_SIZE+1];
68 memset(expected, 0x00, CONVERT_BUFFER_SIZE+1);
69 Uint16 *buffer = cmv.getConvertBuffer();
70
71 // 1文字 -> 1文字
72 cmv.addChar('a');
73 expected[0] = 0x3042;
74 CPPUNIT_ASSERT_MESSAGE("あ", isEqualArray(expected, buffer, 2));
75
76 // 2文字 -> 1文字
77 cmv.addChar('s');
78 expected[1] = 's';
79 CPPUNIT_ASSERT_MESSAGE("あs", isEqualArray(expected, buffer, 3));
80
81 cmv.addChar('a');
82 expected[1] = 0x3055;
83 CPPUNIT_ASSERT_MESSAGE("あさ", isEqualArray(expected, buffer, 3));
84
85 // 変換文字の削除
86 cmv.deleteLast();
87 expected[1] = 0x00;
88 CPPUNIT_ASSERT_MESSAGE("あ", isEqualArray(expected, buffer, 2));
89
90 // 3文字 -> 2文字
91 cmv.addChar('s');
92 expected[1] = 's';
93 cmv.addChar('y');
94 expected[2] = 'y';
95 CPPUNIT_ASSERT_MESSAGE("あsy", isEqualArray(expected, buffer, 4));
96
97 cmv.addChar('a');
98 expected[1] = 0x3057;
99 expected[2] = 0x3083;
100 CPPUNIT_ASSERT_MESSAGE("あしゃ", isEqualArray(expected, buffer, 4));
101
102 // 2文字 -> 3文字
103 cmv.addChar('v');
104 cmv.addChar('a');
105 expected[3] = 0x3046;
106 expected[4] = 0x309B;
107 expected[5] = 0x3041;
108 CPPUNIT_ASSERT_MESSAGE("あしゃう゛ぁ", isEqualArray(expected, buffer, 7));
109
110
111 // "cde" の変換テスト
112 cmv.clearBuffer();
113 memset(expected, 0x00, CONVERT_BUFFER_SIZE);
114 cmv.addChar('c');
115 cmv.addChar('d');
116 cmv.addChar('e');
117 expected[0] = 'c';
118 expected[1] = 0x3067;
119 CPPUNIT_ASSERT_MESSAGE("cば", isEqualArray(expected, buffer, 3));
120
121
122 // "kka" の変換テスト
123 cmv.clearBuffer();
124 memset(expected, 0x00, CONVERT_BUFFER_SIZE);
125 cmv.addChar('k');
126 cmv.addChar('k');
127 cmv.addChar('a');
128 expected[0] = 0x3063;
129 expected[1] = 0x304b;
130 CPPUNIT_ASSERT_MESSAGE("っか", isEqualArray(expected, buffer, 3));
131
132 // tkiyo Ctrl-h * 4, u で、つ になるようにする
133 // !!!
134 #endif
135 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26