Salome HOME
More verifications on links in parallel loops.
[modules/yacs.git] / src / engine / Test / engineIntegrationTest.hxx
1 // Copyright (C) 2006-2015  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_SUITE_END();
74     public:
75       void setUp();
76       void tearDown();
77       void testBloc1();
78       void testBloc2();
79       void testBloc3();
80       void testBloc4();
81       void testSwitch();
82       void testSwitch2();
83       void testSwitch3();
84       void testForLoop1();
85       void testForLoop2();
86       void testForLoop3();
87       void testForLoop4();
88       void testForLoop5();
89       void testWhileLoop1();
90       void testWhileLoop2();
91       void testEdInitOnLoops();
92       void testLinkUpdate1();
93       void testLinkUpdate1DS();
94       void testLinkUpdate2();
95       void testLinkUpdate2DS();
96       void testLinkUpdate3();
97       void testLinkUpdate4();
98       void testInterLoopDFLink();
99       void deathTestForLinks();
100       void testForEachLoop1();
101       void testForEachLoop2();
102       void testForEachLoop3();
103       void testForEachLoop4();
104       void testForEachLoop5();
105       void testForOptimizerLoop1();
106       void testForOptimizerLoop2();
107       void testForOptimizerLoop3();
108       void testForDeployment1();
109       void testForDeployment2();
110       void testForCheckConsistency1();
111       void testForCheckConsistency2();
112       void testForCheckConsistency3();
113       void testForCheckConsistency4();
114       void testRemoveRuntime();
115     protected:
116       template<class T>
117       static void checkListsEqual(const std::list<T>& setToTest1, const std::list<T>& setToTest2);
118       template<class T>
119       static void checkSetsEqual(const std::set<T>& setToTest1, const std::set<T>& setToTest2);
120       template<class T>
121       static void checkSetsNotEqual(const std::set<T *>& setToTest1, const std::set<T *>&setToTest2);
122     };
123
124     template<class T>
125     void EngineIntegrationTest::checkListsEqual(const std::list<T>& setToTest1, const std::list<T>& setToTest2)
126     {
127       typename std::list<T>::iterator iter1=setToTest1.begin();
128       typename std::list<T>::iterator iter2=setToTest2.begin();
129       CPPUNIT_ASSERT_EQUAL_MESSAGE("Lists can't be equal : size different", (int)setToTest1.size(), (int)setToTest2.size());
130       for(;iter1!=setToTest1.end();iter1++,iter2++)
131         CPPUNIT_ASSERT_MESSAGE("Lists can't be equal : value different", *iter1==*iter2);
132     }
133
134     template<class T>
135     void EngineIntegrationTest::checkSetsEqual(const std::set<T>& setToTest1, const std::set<T>& setToTest2)
136     {
137       typename std::set<T>::const_iterator iter1=setToTest1.begin();
138       typename std::set<T>::const_iterator iter2=setToTest2.begin();
139       CPPUNIT_ASSERT_EQUAL_MESSAGE("Sets can't be equal : size different", (int)setToTest1.size(), (int)setToTest2.size());
140       for(;iter1!=setToTest1.end();iter1++,iter2++)
141         CPPUNIT_ASSERT_MESSAGE("Sets can't be equal : value different", *iter1==*iter2);
142     }
143     
144     template<class T>
145     void EngineIntegrationTest::checkSetsNotEqual(const std::set<T *>& setToTest1, const std::set<T *>&setToTest2)
146     {
147       typename std::set<T *>::const_iterator iter1=setToTest1.begin();
148       CPPUNIT_ASSERT_EQUAL_MESSAGE("Sets can't be equal : size different", (int)setToTest1.size(), (int)setToTest2.size());
149       for(;iter1!=setToTest1.end();iter1++)
150         CPPUNIT_ASSERT_MESSAGE("Elements is in set : not expected.",setToTest2.find(*iter1)==setToTest2.end());
151     }
152   }
153 }
154
155 #endif