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