Salome HOME
copyrights in HYDRO files are updated
[modules/hydro.git] / src / HYDROData / test_HYDROData_Main.cxx
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include <cppunit/extensions/TestFactoryRegistry.h>
24 #include <cppunit/CompilerOutputter.h>
25 #include <cppunit/TestResult.h>
26 #include <cppunit/TestResultCollector.h>
27 #include <cppunit/TestRunner.h>
28 #include <cppunit/TextTestProgressListener.h>
29 #include <stdexcept>
30
31 int 
32   main( int argc, char* argv[] )
33 {
34   std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
35
36   // Create the event manager and test controller
37   CppUnit::TestResult controller;
38
39   // Add a listener that colllects test result
40   CppUnit::TestResultCollector result;
41   controller.addListener( &result );        
42
43   // Add a listener that print dots as test run.
44   CppUnit::TextTestProgressListener progress;
45   controller.addListener( &progress );      
46
47   CppUnit::TestFactoryRegistry& registry = 
48     CppUnit::TestFactoryRegistry::getRegistry();
49   // Add the top suite to the test runner
50   CppUnit::TestRunner runner;
51   runner.addTest( registry.makeTest() );   
52   try
53   {
54     std::cout << "Running "  <<  testPath;
55     runner.run( controller, testPath );
56
57     std::cerr << std::endl;
58
59     // Print test in a compiler compatible format.
60     CppUnit::CompilerOutputter outputter( &result, std::cerr );
61     outputter.write();                      
62   }
63   catch ( std::invalid_argument &e )  // Test path not resolved
64   {
65     std::cerr  <<  std::endl  
66       <<  "ERROR: "  <<  e.what()
67       << std::endl;
68     return 0;
69   }
70
71   return result.wasSuccessful() ? 0 : 1;
72 }