unit_part.test.cc

Go to the documentation of this file.
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 unit_part.
00030   \author pt
00031 */
00032 #include <lestes/common.hh>
00033 #include <lestes/std/file_info.hh>
00034 #include <lestes/std/source_location.hh>
00035 #include <lestes/lang/cplus/lex/unit_part.hh>
00036 #include <lestes/lang/cplus/lex/pp_token.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/macro_storage.hh>
00040 
00041 package(lestes);
00042 package(lang);
00043 package(cplus);
00044 package(lex);
00045 
00046 using namespace ::std;
00047 
00048 void unit_part_test(void)
00049 {
00050         char inp[] = "+\n";
00051         pp_token_type out[] = { pp_token::TOK_PLUS, pp_token::TOK_LINE_END, pp_token::TOK_FILE_END };
00052         ptr<file_info> fi = file_info::create("abcd",NULL);
00053         ptr<unit_part> up =
00054                 unit_part::create(fi,string_source::create(inp),encoder_host::create(),macro_storage::create());
00055         ptr<pp_token> tok;
00056         
00057         ulint i = 0;
00058         do {
00059                 
00060                 tok = up->read();
00061 #if 0
00062                 ::std::cerr << " test " << i << " : " <<
00063                         tok->name_get() << " " <<
00064                         tok->type_get() << " ?== " << (int)out[i] << ""
00065                         << ::std::endl;
00066 #if 0         
00067                         (int)tok->value_get() << " ?== " << (int)ouv[i] << " offset " <<
00068                         (int)tok->location_get()->offset_get() << " ?== " << loc[i]->offset_get() << " line " <<
00069                         (int)tok->location_get()->line_get() << " ?== " << loc[i]->line_get() << " column " <<
00070                         (int)tok->location_get()->column_get() << " ?== " << loc[i]->column_get() << " order " <<
00071                         (int)tok->location_get()->order_get() << " ?== " << loc[i]->order_get() << ::std::endl;
00072 #endif
00073 #endif
00074                 lassert(is_equal(tok->type_get(),out[i]));
00075 
00076                 if (tok->type_get() == pp_token::TOK_FILE_END) break;
00077                 i++;
00078         } while (true);
00079 }
00080 
00081 end_package(lex);
00082 end_package(cplus);
00083 end_package(lang);
00084 end_package(lestes);
00085 
00086 int main(void)
00087 {
00088 	::lestes::lang::cplus::lex::unit_part_test();
00089         return 0;
00090 }
00091 /* vim: set ft=lestes : */
00092 

Generated on Mon Feb 12 18:23:44 2007 for lestes by doxygen 1.5.1-20070107