00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <lestes/common.hh>
00035 #include <lestes/lang/cplus/lex/string_source.hh>
00036 #include <lestes/lang/cplus/lex/encoder_ascii7.hh>
00037
00038 package(lestes);
00039 package(lang);
00040 package(cplus);
00041 package(lex);
00042
00043 using namespace ::std;
00044
00045 #define TEST_CNT 9
00046
00047
00048
00049
00050
00051
00052 void encoder_ascii7_test(void)
00053 {
00054 char *in[TEST_CNT] = {
00055
00056 "\x01"
00057 ,
00058
00059 "\x4D"
00060 ,
00061
00062 "\x7E"
00063 ,
00064
00065 "\x7F"
00066 ,
00067
00068 "\x80"
00069 ,
00070
00071 "\x81"
00072 ,
00073
00074 "\x90"
00075 ,
00076
00077 "\xAF"
00078 ,
00079
00080 "\xFF"
00081 };
00082
00083 ucn_token_type out[] = {
00084 ucn_token::TOK_NOT_EOF,
00085 ucn_token::TOK_EOF,
00086 ucn_token::TOK_NOT_EOF,
00087 ucn_token::TOK_EOF,
00088 ucn_token::TOK_NOT_EOF,
00089 ucn_token::TOK_EOF,
00090 ucn_token::TOK_NOT_EOF,
00091 ucn_token::TOK_EOF,
00092 ucn_token::TOK_ERROR,
00093 ucn_token::TOK_ERROR,
00094 ucn_token::TOK_ERROR,
00095 ucn_token::TOK_ERROR,
00096 ucn_token::TOK_ERROR,
00097 };
00098
00099 ptr<ucn_token> tok;
00100 ucn_token_type utt;
00101 ulint test, i;
00102
00103 for (i = test = 0; test < TEST_CNT; test++) {
00104 ptr<data_source> ds = string_source::create(string_source::string_type(in[test]));
00105 ptr<encoder_ascii7> enc = encoder_ascii7::create();
00106
00107 enc->input_set(ds);
00108
00109 while (true) {
00110 tok = enc->read();
00111 utt = tok->type_get();
00112 lassert(utt == out[i]);
00113 i++;
00114 if (utt == ucn_token::TOK_EOF || utt == ucn_token::TOK_ERROR) break;
00115 }
00116 }
00117 }
00118
00119 end_package(lex);
00120 end_package(cplus);
00121 end_package(lang);
00122 end_package(lestes);
00123
00124
00125
00126
00127
00128
00129 int main(void)
00130 {
00131 ::lestes::lang::cplus::lex::encoder_ascii7_test();
00132 return 0;
00133 }
00134