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