reporter.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 reporter.
00032   \author pt
00033 */
00034 #include <lestes/common.hh>
00035 #include <lestes/equality.hh>
00036 #include <lestes/std/file_info.hh>
00037 #include <lestes/std/source_location.hh>
00038 #include <lestes/msg/message.hh>
00039 #include <lestes/msg/report_end.hh>
00040 #include <lestes/msg/report_cache.hh>
00041 #include <lestes/msg/report_ostream.hh>
00042 #include <lestes/std/ostream_wrapper.hh>
00043 #include <lestes/msg/reporter.test.hh>
00044 #include <lestes/msg/reporter.test.m.hh>
00045 
00046 package(lestes);
00047 package(msg);
00048 
00049 using namespace ::std;
00050 
00051 /*!
00052   \brief Tests reporter class.
00053 
00054   Performs testing of reporter class.
00055 */
00056 void reporter_test(void)
00057 {
00058         ptr<report_cache> rc = report_cache::create(report_end::create());
00059         lassert(is_equal(rc->location_get(),ptr<source_location>(NULL)));
00060         lassert(is_equal(rc->message_get(),ptr<message>(NULL)));
00061 
00062         //ptr<report_ostream> ro = report_ostream::create(rc,ostream_wrapper::create(&::std::cout,false));
00063         
00064         ptr<reporter> rep = reporter::instance();
00065         
00066         rep->filter_set(rc);
00067         //rep->filter_set(ro);
00068         
00069         ptr<file_info> fi = file_info::create("ab.c",NULL);
00070         ptr<source_location> loc = source_location::create(fi,1,1);
00071         
00072         ptr<message> m0 = message::create(test0->kind_get(),"Test 0.",message::FLG_WARNING);
00073         
00074         report << test0 << loc;
00075         lassert(is_equal(rc->location_get(),loc));
00076         lassert(is_equal(rc->message_get(),m0));
00077 
00078         ptr<message> m1 = message::create(test1->kind_get(),"Test 1: abcd.",message::FLG_ERROR);
00079         
00080         report << test1 << lstring("abcd") << loc;
00081         lassert(is_equal(rc->location_get(),loc));
00082         lassert(is_equal(rc->message_get(),m1));
00083 
00084         ptr<message> m2 = message::create(test2->kind_get(),"Test 2: 37 65.",message::FLG_ERROR);
00085         report << test2 << 37U << 65U << loc;
00086         lassert(is_equal(rc->location_get(),loc));
00087         lassert(is_equal(rc->message_get(),m2));
00088         
00089         ptr<message> m3 = message::create(test3->kind_get(),"Test 3: all your base are belong to 8472.",message::FLG_WARNING);
00090         lstring s("are belong to"), t("all your base");
00091         ulint u = 8472;
00092         report << test3 << s << u << t << loc;
00093         lassert(is_equal(rc->location_get(),loc));
00094         lassert(is_equal(rc->message_get(),m3));
00095 }
00096 
00097 end_package(msg);
00098 end_package(lestes);
00099 
00100 /*!
00101   \brief Main function.
00102 
00103   Runs the unit test in different namespace.
00104 */
00105 int main(void)
00106 {
00107 	::lestes::msg::reporter_test();
00108         return 0;
00109 }
00110 /* vim: set ft=lestes : */

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