condition.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   \brief Unit test.
00030 
00031   Unit test for class condition.
00032   \author pt
00033 */
00034 #include <lestes/common.hh>
00035 #include <lestes/equality.hh>
00036 #include <lestes/lang/cplus/lex/condition.hh>
00037 #include <lestes/std/file_info.hh>
00038 #include <lestes/std/source_location.hh>
00039 
00040 package(lestes);
00041 package(lang);
00042 package(cplus);
00043 package(lex);
00044 
00045 using namespace ::std;
00046 
00047 /*!
00048   \brief Tests condition class.
00049 
00050   Performs testing of condition class.
00051 */
00052 void condition_test(void)
00053 {
00054         ptr<source_location> loc = source_location::create(file_info::create("abc",NULL),1,1);
00055 
00056         // empty condition
00057         ptr<condition> c0 = condition::create_empty();
00058         lassert(is_equal(c0,c0));
00059         lassert(is_equal(c0->type_get(),condition::COND_EMPTY));
00060         lassert(is_equal(c0->active_get(),true));
00061 
00062         // normal condition
00063         ptr<condition> c1 = condition::create(condition::COND_IF,true,false,loc);
00064         lassert(is_equal(c1,c1));
00065         lassert(!is_equal(c1,c0));
00066         lassert(is_equal(c1->type_get(),condition::COND_IF));
00067         lassert(is_equal(c1->waiting_get(),true));
00068         lassert(is_equal(c1->active_get(),false));
00069         lassert(is_equal(c1->location_get(),loc));
00070 
00071         // another normal condition
00072         ptr<condition> c2 = condition::create(condition::COND_ELIF,false,true,loc);
00073         lassert(is_equal(c2,c2));
00074         lassert(!is_equal(c2,c1));
00075         lassert(is_equal(c2->type_get(),condition::COND_ELIF));
00076         lassert(is_equal(c2->waiting_get(),false));
00077         lassert(is_equal(c2->active_get(),true));
00078         lassert(is_equal(c2->location_get(),loc));
00079 
00080         // same condition
00081         ptr<condition> c3 = condition::create(condition::COND_ELIF,false,true,loc);
00082         lassert(is_equal(c3,c3));
00083         lassert(!is_equal(c3,c1));
00084         lassert(is_equal(c3,c2));
00085         lassert(is_equal(c2->type_get(),condition::COND_ELIF));
00086         lassert(is_equal(c2->waiting_get(),false));
00087         lassert(is_equal(c2->active_get(),true));
00088         lassert(is_equal(c2->location_get(),loc));
00089 }
00090 
00091 end_package(lex);
00092 end_package(cplus);
00093 end_package(lang);
00094 end_package(lestes);
00095 
00096 /*!
00097   \brief Main function.
00098 
00099   Runs the unit test in different namespace.
00100 */
00101 int main(void)
00102 {
00103 	::lestes::lang::cplus::lex::condition_test();
00104         return 0;
00105 }
00106 /* vim: set ft=lestes : */

Generated on Mon Feb 12 18:22:32 2007 for lestes by doxygen 1.5.1-20070107