unittest/memory/main.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 // TerraLib
21 #include <terralib/memory_fw.h>
22 
23 #include <terralib/common/Module.h>
24 //#include <terralib/dataaccess/Module.h>
25 //#include <terralib/geometry/Module.h>
26 #include <terralib/core/plugin.h>
27 
28 // cppUnit
29 #include <cppunit/BriefTestProgressListener.h>
30 #include <cppunit/CompilerOutputter.h>
31 #include <cppunit/XmlOutputter.h>
32 #include <cppunit/TextOutputter.h>
33 
34 #include <cppunit/extensions/HelperMacros.h>
35 #include <cppunit/extensions/TestFactoryRegistry.h>
36 #include <cppunit/TestResult.h>
37 #include <cppunit/TestResultCollector.h>
38 #include <cppunit/TestRunner.h>
39 
40 //#include <terralib/common/TerraLib.h>
41 //#include <terralib/common.h>
42 //#include <terralib/core/plugin.h>
43 
44 // Unit-Test TerraLib includes by platform
45 #include "Config.h"
46 
47 #include <cstdlib>
48 
49 #define TS_TEST_NAME "testResult_memory"
50 
51 int main(int /*argc*/, char** /*argv*/)
52 {
53  // it creates the event manager and test controller
54  CPPUNIT_NS::TestResult controller;
55 
56  // it adds a listener that collects test result
57  CPPUNIT_NS::TestResultCollector result;
58 
59  controller.addListener(&result);
60 
61  // it adds a listener that print dots as test run.
62  CPPUNIT_NS::BriefTestProgressListener progress;
63 
64  controller.addListener(&progress);
65 
66  // it adds the top suite to the test runner
67  CppUnit::Test* suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
68 
69  CPPUNIT_NS::TestRunner runner;
70 
71  runner.addTest(suite);
72 
73  runner.run(controller);
74 
75  CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
76  outputter.write();
77 
78 // Testing different outputs...
79 
80 // Print only fail results in a txt file (the same containt you see in DOS window)
81  std::ofstream file1(TERRALIB_REPORT_DIR "/" TS_TEST_NAME ".txt" );
82  CPPUNIT_NS::CompilerOutputter outputter1( &result, file1);
83  outputter1.write();
84  file1.close();
85 
86 // Printing testResults in XML file
87  // The testResult_*.xml files will be saved at TERRALIB_REPORT_DIR directory.
88  // The styleSheet 'report.xsl' should be at this directory (found originally at <third-party-lib>\cppunit-1.12.1\contrib\xml-xsl).
89  // The "data.zip" (downloaded) containing the data used in unit tests should be at TERRALIB_DATA_DIR
90 
91  CPPUNIT_NS::OFileStream file2(TERRALIB_REPORT_DIR "/" TS_TEST_NAME ".xml");
92  CPPUNIT_NS::XmlOutputter xml( &result, file2 );
93  xml.setStyleSheet( "report.xsl" );
94  xml.write();
95  file2.close();
96 
97 // Print formated testResult in a txt
98  CPPUNIT_NS::OFileStream file3(TERRALIB_REPORT_DIR "/" TS_TEST_NAME ".txt" );
99  CPPUNIT_NS::TextOutputter outputter3( &result, file3 );
100  outputter3.write();
101  file3.close();
102 
103  bool resultStatus = result.wasSuccessful();
104 
105  return resultStatus ? EXIT_SUCCESS : EXIT_FAILURE;
106 }
107 
Include files for Core Plugin Library.
#define TS_TEST_NAME
int main(int, char **)
This singleton defines an entry in the Platform for the TerraLib Common Runtime module.