00001 /* 00002 The lestes compiler suite 00003 Copyright (C) 2002, 2003, 2004, 2005 Miroslav Tichy 00004 Copyright (C) 2002, 2003, 2004, 2005 Petr Zika 00005 Copyright (C) 2002, 2003, 2004, 2005 Vojtech Hala 00006 Copyright (C) 2002, 2003, 2004, 2005 Jiri Kosina 00007 Copyright (C) 2002, 2003, 2004, 2005 Pavel Sanda 00008 Copyright (C) 2002, 2003, 2004, 2005 Jan Zouhar 00009 Copyright (C) 2002, 2003, 2004, 2005 Rudolf Thomas 00010 00011 This program is free software; you can redistribute it and/or modify 00012 it under the terms of the GNU General Public License as published by 00013 the Free Software Foundation; version 2 of the License. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 See the full text of the GNU General Public License version 2, and 00021 the limitations in the file doc/LICENSE. 00022 00023 By accepting the license the licensee waives any and all claims 00024 against the copyright holder(s) related in whole or in part to the 00025 work, its use, and/or the inability to use it. 00026 00027 */ 00028 /*! \file 00029 Unit test for class trigraphs. 00030 \todo Not updated for the new situation. 00031 \author pt 00032 */ 00033 #include <lestes/common.hh> 00034 #include <lestes/std/source_location.hh> 00035 #include <lestes/lang/cplus/lex/special_tokens.hh> 00036 #include <lestes/std/file_info.hh> 00037 #include <lestes/lang/cplus/lex/string_source.hh> 00038 #include <lestes/lang/cplus/lex/encoder_host.hh> 00039 #include <lestes/lang/cplus/lex/trigraphs.hh> 00040 #include <string> 00041 00042 package(lestes); 00043 package(lang); 00044 package(cplus); 00045 package(lex); 00046 00047 using namespace ::std; 00048 00049 void trigraphs_test(void) 00050 { 00051 char in[] = "?""?= ?""?/ ?""?( ?""?) ?""?! ?""?< ?""?> ?""?- ?""?' \\?""?/ ?\\?/\n"; 00052 char out[] = "# \\ [ ] | { } ~ ^ \\\\ ?\\?/\n"; 00053 lint i; 00054 ptr<file_info> fi = file_info::create(string("abcd"),NULL); 00055 ptr<data_source> ds = string_source::create(in); 00056 ptr<encoder_host> enc = encoder_host::create(); 00057 ptr<special_tokens> stok = special_tokens::create(); 00058 ptr<trigraphs> tri = trigraphs::create(); 00059 ptr<ucn_token> tok; 00060 00061 enc->input_set(ds); 00062 stok->input_set(enc); 00063 tri->input_set(stok); 00064 00065 i = 0; 00066 do { 00067 tok = tri->read(); 00068 //cout << i << ": " << (char)tok.get_value() << endl; 00069 if (tok->type_get() == ucn_token::TOK_EOF) break; 00070 lassert((char)tok->value_get() == out[i]); 00071 00072 i++; 00073 } while (true); 00074 } 00075 00076 end_package(lex); 00077 end_package(cplus); 00078 end_package(lang); 00079 end_package(lestes); 00080 00081 int main(void) 00082 { 00083 ::lestes::lang::cplus::lex::trigraphs_test(); 00084 return 0; 00085 } 00086 /* vim: set ft=lestes : */
1.5.1-20070107