unittest/geometry/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 #include "../Config.h"
21 
22 // TerraLib
23 #include <terralib/common.h>
24 #include <terralib/geometry.h>
25 
26 // cppUnit
27 #include <cppunit/BriefTestProgressListener.h>
28 #include <cppunit/CompilerOutputter.h>
29 #include <cppunit/XmlOutputter.h>
30 #include <cppunit/TextOutputter.h>
31 
32 #include <cppunit/extensions/HelperMacros.h>
33 #include <cppunit/extensions/TestFactoryRegistry.h>
34 #include <cppunit/TestResult.h>
35 #include <cppunit/TestResultCollector.h>
36 #include <cppunit/TestRunner.h>
37 
38 int main(int /*argc*/, char** /*argv*/)
39 {
41 
42 // it creates the event manager and test controller
43  CPPUNIT_NS::TestResult controller;
44 
45 // it adds a listener that colllects test result
46  CPPUNIT_NS::TestResultCollector result;
47 
48  controller.addListener(&result);
49 
50 // it adds a listener that print dots as test run.
51  CPPUNIT_NS::BriefTestProgressListener progress;
52 
53  controller.addListener(&progress);
54 
55 // it adds the top suite to the test runner
56  CppUnit::Test* suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
57 
58  CPPUNIT_NS::TestRunner runner;
59 
60  runner.addTest(suite);
61 
62  runner.run(controller);
63 
64  CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
65 
66  outputter.write();
67 
68 // Testing different outputs
69 
70 // Print only fail results in a txt file (the same you can see in DOS window)
71  std::ofstream file1( TERRALIB_REPORT_DIR "/testsResult_geometry_dos.txt" );
72  CPPUNIT_NS::CompilerOutputter outputter1( &result, file1);
73  outputter1.write();
74  file1.close();
75 
76 // Printing testResults in XML file
77 // Testing different outputs
78  // The testResult_*.xml files will be saved at TERRALIB_REPORT_DIR directory.
79  // The styleSheet 'report.xsl' should be at this directory (found originally at <third-party-lib>\cppunit-1.12.1\contrib\xml-xsl).
80  // The "data.zip" (downloaded) containing the data used in unit tests should be at TERRALIB_DATA_DIR
81 
82  CPPUNIT_NS::OFileStream file2( TERRALIB_REPORT_DIR "/testsResult_geometry_xml.xml" );
83  CPPUNIT_NS::XmlOutputter xml( &result, file2 );
84  xml.setStyleSheet( "report.xsl" );
85  xml.write();
86  file2.close();
87 
88 // Print formated testResult in a txt
89  CPPUNIT_NS::OFileStream file3( TERRALIB_REPORT_DIR "/testsResult_geometry_formated.txt" );
90  CPPUNIT_NS::TextOutputter outputter3( &result, file3 );
91  outputter3.write();
92  file3.close();
93 
94  bool resultStatus = result.wasSuccessful();
95 
97 
98  return resultStatus ? EXIT_SUCCESS : EXIT_FAILURE;
99 }
100 
int main(int, char **)
void finalize()
It finalizes the TerraLib Platform.
static TerraLib & getInstance()
It returns a reference to the singleton instance.
void initialize()
It initializes the TerraLib Platform.
This file contains include headers for the TerraLib Common Runtime module.
This file contains include headers for the Vector Geometry model of TerraLib.