TestJpTextConverter.cpp

Go to the documentation of this file.
00001 
00010 #include "TestJpTextConverter.h"
00011 #include "ArrayTestUtil.h"
00012 
00013 
00014 CPPUNIT_TEST_SUITE_REGISTRATION(TestJpTextConverter);
00015 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(TestJpTextConverter,
00016                                       "TestJpTextConverter");
00017 
00018 #if 0
00019 // バッファの長さを返す
00020 static int getBufferLength(Uint16 buffer[]) {
00021   int length = 0;
00022   while (buffer[length] != 0x00) {
00023     ++length;
00024   }
00025   return length;
00026 }
00027 #endif
00028 
00029 
00030 // 基本操作の動作確認
00031 void TestJpTextConverter::bufferCtrlTest(void) {
00032 
00033   CPPUNIT_FAIL("Not implemented.");
00034 
00035 #if 0
00036   RomanJpConverter cmv;
00037   Uint16 *buffer = cmv.getConvertBuffer();
00038 
00039   CPPUNIT_ASSERT_EQUAL(0, getBufferLength(buffer));
00040 
00041   cmv.addChar('c');
00042 
00043   CPPUNIT_ASSERT_EQUAL(1, getBufferLength(buffer));
00044 
00045   cmv.addChar('b');
00046   CPPUNIT_ASSERT_EQUAL(2, getBufferLength(buffer));
00047 
00048   cmv.deleteLast();
00049   CPPUNIT_ASSERT_EQUAL(1, getBufferLength(buffer));
00050 
00051   cmv.deleteLast();
00052   CPPUNIT_ASSERT_EQUAL(0, getBufferLength(buffer));
00053 
00054   cmv.deleteLast();
00055   CPPUNIT_ASSERT_EQUAL(0, getBufferLength(buffer));
00056 #endif
00057 }
00058 
00059 
00060 // ローマ字変換のテスト
00061 void TestJpTextConverter::romaConvertTest(void) {
00062 
00063   CPPUNIT_FAIL("Not implemented.");
00064 
00065 #if 0
00066   Convert cmv;
00067   Uint16 expected[CONVERT_BUFFER_SIZE+1];
00068   memset(expected, 0x00, CONVERT_BUFFER_SIZE+1);
00069   Uint16 *buffer = cmv.getConvertBuffer();
00070 
00071   // 1文字 -> 1文字
00072   cmv.addChar('a');
00073   expected[0] = 0x3042;
00074   CPPUNIT_ASSERT_MESSAGE("あ", isEqualArray(expected, buffer, 2));
00075 
00076   // 2文字 -> 1文字
00077   cmv.addChar('s');
00078   expected[1] = 's';
00079   CPPUNIT_ASSERT_MESSAGE("あs", isEqualArray(expected, buffer, 3));
00080 
00081   cmv.addChar('a');
00082   expected[1] = 0x3055;
00083   CPPUNIT_ASSERT_MESSAGE("あさ", isEqualArray(expected, buffer, 3));
00084 
00085   // 変換文字の削除
00086   cmv.deleteLast();
00087   expected[1] = 0x00;
00088   CPPUNIT_ASSERT_MESSAGE("あ", isEqualArray(expected, buffer, 2));
00089 
00090   // 3文字 -> 2文字
00091   cmv.addChar('s');
00092   expected[1] = 's';
00093   cmv.addChar('y');
00094   expected[2] = 'y';
00095   CPPUNIT_ASSERT_MESSAGE("あsy", isEqualArray(expected, buffer, 4));
00096 
00097   cmv.addChar('a');
00098   expected[1] = 0x3057;
00099   expected[2] = 0x3083;
00100   CPPUNIT_ASSERT_MESSAGE("あしゃ", isEqualArray(expected, buffer, 4));
00101 
00102   // 2文字 -> 3文字
00103   cmv.addChar('v');
00104   cmv.addChar('a');
00105   expected[3] = 0x3046;
00106   expected[4] = 0x309B;
00107   expected[5] = 0x3041;
00108   CPPUNIT_ASSERT_MESSAGE("あしゃう゛ぁ", isEqualArray(expected, buffer, 7));
00109 
00110 
00111   // "cde" の変換テスト
00112   cmv.clearBuffer();
00113   memset(expected, 0x00, CONVERT_BUFFER_SIZE);
00114   cmv.addChar('c');
00115   cmv.addChar('d');
00116   cmv.addChar('e');
00117   expected[0] = 'c';
00118   expected[1] = 0x3067;
00119   CPPUNIT_ASSERT_MESSAGE("cば", isEqualArray(expected, buffer, 3));
00120 
00121 
00122   // "kka" の変換テスト
00123   cmv.clearBuffer();
00124   memset(expected, 0x00, CONVERT_BUFFER_SIZE);
00125   cmv.addChar('k');
00126   cmv.addChar('k');
00127   cmv.addChar('a');
00128   expected[0] = 0x3063;
00129   expected[1] = 0x304b;
00130   CPPUNIT_ASSERT_MESSAGE("っか", isEqualArray(expected, buffer, 3));
00131 
00132   // tkiyo Ctrl-h * 4, u で、つ になるようにする
00133   // !!!
00134 #endif
00135 }
00136 

Generated on Mon Apr 13 22:52:01 2009 by  doxygen 1.5.7.1