Salome HOME
updated copyright message
[modules/yacs.git] / src / engine / Test / engineIntegrationTest.hxx
1 // Copyright (C) 2006-2023  CEA/DEN, EDF R&D
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 #ifndef __ENGINEINTEGRATIONTEST_HXX__
21 #define __ENGINEINTEGRATIONTEST_HXX__
22
23 #include <cppunit/extensions/HelperMacros.h>
24 #include <list>
25
26 namespace YACS
27 {
28   namespace ENGINE
29   {
30     class Task;
31
32     class EngineIntegrationTest : public CppUnit::TestFixture
33     {
34       CPPUNIT_TEST_SUITE( EngineIntegrationTest );
35       CPPUNIT_TEST( testBloc1 );
36       CPPUNIT_TEST( testBloc2 );
37       CPPUNIT_TEST( testBloc3 );
38       CPPUNIT_TEST( testBloc4 );
39       CPPUNIT_TEST( testForLoop1 );
40       CPPUNIT_TEST( testForLoop2 );
41       CPPUNIT_TEST( testForLoop3 );
42       CPPUNIT_TEST( testForLoop4 );
43       CPPUNIT_TEST( testForLoop5 );
44       CPPUNIT_TEST( testWhileLoop1 );
45       CPPUNIT_TEST( testWhileLoop2 );
46       CPPUNIT_TEST( testSwitch );
47       CPPUNIT_TEST( testSwitch2 );
48       CPPUNIT_TEST( testSwitch3 );
49       CPPUNIT_TEST( testEdInitOnLoops );
50       CPPUNIT_TEST( testLinkUpdate1 );
51       CPPUNIT_TEST( testLinkUpdate1DS );
52       CPPUNIT_TEST( testLinkUpdate2 );
53       CPPUNIT_TEST( testLinkUpdate2DS );
54       CPPUNIT_TEST( testLinkUpdate3 );
55       CPPUNIT_TEST( testLinkUpdate4 );
56       CPPUNIT_TEST( testInterLoopDFLink );
57       CPPUNIT_TEST( deathTestForLinks );
58       CPPUNIT_TEST( testForEachLoop1 );
59       CPPUNIT_TEST( testForEachLoop2 );
60       CPPUNIT_TEST( testForEachLoop3 );
61       CPPUNIT_TEST( testForEachLoop4 );
62       CPPUNIT_TEST( testForEachLoop5 );
63       CPPUNIT_TEST( testForOptimizerLoop1 );
64       CPPUNIT_TEST( testForOptimizerLoop2 );
65       CPPUNIT_TEST( testForOptimizerLoop3 );
66       CPPUNIT_TEST( testForDeployment1 );
67       CPPUNIT_TEST( testForDeployment2 );
68       CPPUNIT_TEST( testForCheckConsistency1 );
69       CPPUNIT_TEST( testForCheckConsistency2 );
70       CPPUNIT_TEST( testForCheckConsistency3 );
71       CPPUNIT_TEST( testForCheckConsistency4 );
72       CPPUNIT_TEST( testRemoveRuntime );
73       CPPUNIT_TEST( testWrongNodeNameDetection );
74       CPPUNIT_TEST_SUITE_END();
75     public:
76       void setUp();
77       void tearDown();
78       void testBloc1();
79       void testBloc2();
80       void testBloc3();
81       void testBloc4();
82       void testSwitch();
83       void testSwitch2();
84       void testSwitch3();
85       void testForLoop1();
86       void testForLoop2();
87       void testForLoop3();
88       void testForLoop4();
89       void testForLoop5();
90       void testWhileLoop1();
91       void testWhileLoop2();
92       void testEdInitOnLoops();
93       void testLinkUpdate1();
94       void testLinkUpdate1DS();
95       void testLinkUpdate2();
96       void testLinkUpdate2DS();
97       void testLinkUpdate3();
98       void testLinkUpdate4();
99       void testInterLoopDFLink();
100       void deathTestForLinks();
101       void testForEachLoop1();
102       void testForEachLoop2();
103       void testForEachLoop3();
104       void testForEachLoop4();
105       void testForEachLoop5();
106       void testForOptimizerLoop1();
107       void testForOptimizerLoop2();
108       void testForOptimizerLoop3();
109       void testForDeployment1();
110       void testForDeployment2();
111       void testForCheckConsistency1();
112       void testForCheckConsistency2();
113       void testForCheckConsistency3();
114       void testForCheckConsistency4();
115       void testRemoveRuntime();
116       void testWrongNodeNameDetection();
117     protected:
118       template<class T>
119       static void checkListsEqual(const std::list<T>& setToTest1, const std::list<T>& setToTest2);
120       template<class T>
121       static void checkSetsEqual(const std::set<T>& setToTest1, const std::set<T>& setToTest2);
122       template<class T>
123       static void checkSetsNotEqual(const std::set<T *>& setToTest1, const std::set<T *>&setToTest2);
124     };
125
126     template<class T>
127     void EngineIntegrationTest::checkListsEqual(const std::list<T>& setToTest1, const std::list<T>& setToTest2)
128     {
129       typename std::list<T>::iterator iter1=setToTest1.begin();
130       typename std::list<T>::iterator iter2=setToTest2.begin();
131       CPPUNIT_ASSERT_EQUAL_MESSAGE("Lists can't be equal : size different", (int)setToTest1.size(), (int)setToTest2.size());
132       for(;iter1!=setToTest1.end();iter1++,iter2++)
133         CPPUNIT_ASSERT_MESSAGE("Lists can't be equal : value different", *iter1==*iter2);
134     }
135
136     template<class T>
137     void EngineIntegrationTest::checkSetsEqual(const std::set<T>& setToTest1, const std::set<T>& setToTest2)
138     {
139       typename std::set<T>::const_iterator iter1=setToTest1.begin();
140       typename std::set<T>::const_iterator iter2=setToTest2.begin();
141       CPPUNIT_ASSERT_EQUAL_MESSAGE("Sets can't be equal : size different", (int)setToTest1.size(), (int)setToTest2.size());
142       for(;iter1!=setToTest1.end();iter1++,iter2++)
143         CPPUNIT_ASSERT_MESSAGE("Sets can't be equal : value different", *iter1==*iter2);
144     }
145     
146     template<class T>
147     void EngineIntegrationTest::checkSetsNotEqual(const std::set<T *>& setToTest1, const std::set<T *>&setToTest2)
148     {
149       typename std::set<T *>::const_iterator iter1=setToTest1.begin();
150       CPPUNIT_ASSERT_EQUAL_MESSAGE("Sets can't be equal : size different", (int)setToTest1.size(), (int)setToTest2.size());
151       for(;iter1!=setToTest1.end();iter1++)
152         CPPUNIT_ASSERT_MESSAGE("Elements is in set : not expected.",setToTest2.find(*iter1)==setToTest2.end());
153     }
154   }
155 }
156
157 #endif