Salome HOME
Updated copyright comment
[modules/hexablock.git] / src / TEST_CPP / Test_HEXABLOCK.cxx
1 // Copyright (C) 2009-2024  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include <cppunit/BriefTestProgressListener.h>
21 #include <cppunit/CompilerOutputter.h>
22 #include <cppunit/extensions/TestFactoryRegistry.h>
23 #include <cppunit/TestResult.h>
24 #include <cppunit/TestResultCollector.h>
25 #include <cppunit/TestRunner.h>
26 #include <cppunit/XmlOutputter.h>
27
28 #include "test_unit.hxx"
29
30 #define TestUnit(call) display(#call); ier=call(nbargs,tabargs); display(ier)
31
32 static int    total_tests  = 0;
33 static int    total_errors = 0;
34 static cpchar test_name    = "Unknown";
35
36 static void display (cpchar name);
37 static void display (int ier);
38
39 // ============================================================== Main
40 int main (int nbargs, cpchar tabargs [])
41 {
42    int ier;
43
44    goto_workspace ();
45
46    TestUnit (test_sphere );
47    TestUnit (test_joint );
48    TestUnit (test_prism );
49    TestUnit (test_revolution9 );
50    TestUnit (test_revolution );
51    TestUnit (test_coude );
52    TestUnit (test_count );
53    TestUnit (test_decoupage );
54    // TestUnit (test_gen_xml );
55    // TestUnit (test_string_xml );
56    ///   TestUnit (test_relecture );
57    TestUnit (test_spherical);
58    TestUnit (test_grille_cyl );
59    TestUnit (test_cylindrical );
60    TestUnit (test_cylinder );
61    // TestUnit (test_xml_cylinder );
62    TestUnit (test_pipe );
63    TestUnit (test_joint2 );
64    TestUnit (test_croix );
65    TestUnit (test_pipes );
66    TestUnit (test_lorraine);
67    TestUnit (test_disconnect2 );
68    TestUnit (test_disconnect4 );
69    TestUnit (test_disconnect1 );
70    TestUnit (test_disconnect3 );
71    TestUnit (test_disconnect );
72    TestUnit (test_transfo2 );
73    TestUnit (test_transfo );
74    TestUnit (test_copy_document );
75    TestUnit (test_cylindricals );
76                  // Dans test_quads
77    TestUnit (test_hexa_quads_5 );
78    TestUnit (test_hexa_quads_ab );
79    TestUnit (test_hexa_quads_ac );
80    TestUnit (test_hexa_quads_ace );
81    TestUnit (test_hexa_quads_acd );
82    TestUnit (test_hexa_quads_abcd );
83    TestUnit (test_hexa_quads_abce );
84    TestUnit (test_cramer );
85    TestUnit (test_hexa_quads_ac1 );
86    TestUnit (test_asso_grid );
87    TestUnit (test_piquage );
88    TestUnit (test_replace );
89    TestUnit (test_hemispheres );
90
91    free_workspace ();
92
93    cout << "========================================= " 
94         << endl;
95    cout << "==== End of tests : Number of Errors = " << total_errors << " / " << total_tests
96         << endl;
97    cout << "========================================= " 
98         << endl;
99
100    return total_errors==0 ? 0 : 1;
101 }
102
103 // ============================================================== main-type
104 int main_standard (int argc, char* argv[])
105 {
106         // Retrieve test path from command line first argument. Default to "" which resolve
107         // to the top level suite.
108         std::string testPath = (argc > 1) ? std::string(argv[1]) : std::string("");
109         
110         // Create the event manager and test controller
111         CPPUNIT_NS::TestResult controller;
112         
113         // Add a listener that collects test result
114         CPPUNIT_NS::TestResultCollector result;
115         
116         controller.addListener( &result );
117         
118         // Add a listener that print dots as test run.
119         CPPUNIT_NS::BriefTestProgressListener progress;
120         
121         controller.addListener( &progress );
122         
123         // Add the top suite to the test runner
124         CPPUNIT_NS::TestRunner runner;
125         runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
126         runner.run( controller );
127         
128         // Print test in a compiler compatible format.
129         CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
130         outputter.write();
131         
132         // Uncomment this for XML output
133         std::ofstream file( "cppunit-report.xml" );
134         
135         CPPUNIT_NS::XmlOutputter xml( &result, file );
136         
137         xml.write();
138         
139         file.close();
140         
141         return result.wasSuccessful() ? 0 : 1;
142 }
143 // ============================================================= display name
144 void display (cpchar nom)
145 {
146    test_name = nom;
147    cout << endl;
148    cout << "========================================= Run "
149         << test_name << endl;
150 }
151 // ============================================================= display ier
152 void display (int result)
153 {
154    cout << ".........................................."
155         << " End of " << test_name;
156    total_tests++;
157    if (result==0)
158       {
159       cout << ", Successfull";
160       }
161    else {
162       cout << ", Code error = " << result;
163       total_errors++;
164    };
165    cout << endl;
166    
167 }