openETCS
case study for the European Train Control System developed for the authors dissertation
UnitTesting.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010-2011
3  Johannes Feuser <feuser@uni-bremen.de>
4  This file is part of the openETCS library.
5 
6  The openETCS library is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  any later version.
10 
11  The openETCS library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with the openETCS library. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 /*!
21  * \author Johannes Feuser <feuser@uni-bremen.de>
22  * \brief unit testing module
23  */
24 
25 #ifndef __OETCS_UT_UNITTESTING_H__
26 #define __OETCS_UT_UNITTESTING_H__
27 
28 
29 #include <cppunit/extensions/HelperMacros.h>
30 #include "GeneratedAsserts/openETCS_Case_Study.h"
31 
32 #include <exception>
33 #include <TestFixture.h>
34 #include <TestCaller.h>
35 #include "../DF/EVCStateMachine.h"
36 #include "../DF/Language.h"
37 #include "../DF/PlatformSpecificClientsMOC.h"
38 #include <map>
39 #include <string>
40 
41 
42 
43 
44 namespace oETCS { namespace DF { class CAnd; } }
45 namespace oETCS { namespace DF { class COr; } }
46 namespace oETCS { namespace DF { class CEVCCondition; } }
47 namespace oETCS { namespace DF { class CCondition; } }
48 namespace oETCS { namespace DF { class CLevelCondition; } }
49 namespace oETCS { namespace DF { class CComBlockIn; } }
50 namespace oETCS { namespace DF { class CComBlockOut; } }
51 namespace oETCS { namespace DF { class CXor; } }
52 namespace oETCS { namespace DF { class CNot; } }
53 namespace oETCS { namespace DF { class CSum; } }
54 namespace oETCS { namespace DF { class CSubstraction; } }
55 namespace oETCS { namespace DF { class CDivision; } }
56 namespace oETCS { namespace DF { class CMultiplication; } }
57 namespace oETCS { namespace DF { class CDoubleEqual; } }
58 namespace oETCS { namespace DF { class CIntEqual; } }
59 namespace oETCS { namespace DF { class CStringEqual; } }
60 namespace oETCS { namespace DF { class CDoubleEqualOrGreater; } }
61 namespace oETCS { namespace DF { class CDoubleGreater; } }
62 namespace oETCS { namespace DF { class CIntGreater; } }
63 namespace oETCS { namespace DF { class CDoubleArrayAccessor; } }
64 namespace oETCS { namespace DF { class CBoolGate; } }
65 namespace oETCS { namespace DF { class CBrakingToTargetSpeed; } }
66 namespace oETCS { namespace DF { class CCeelingSpeedControl; } }
67 namespace oETCS { namespace DF { class CStringGate; } }
68 namespace oETCS { namespace DF { class CDoubleGate; } }
69 namespace oETCS { namespace DF { class CBoolSwitch; } }
70 namespace oETCS { namespace DF { class CDoubleSwitch; } }
71 namespace oETCS { namespace DF { class CStringSwitch; } }
72 namespace oETCS { namespace DF { class CEnteredTrigger; } }
73 namespace oETCS { namespace DF { class CStorage; } }
74 namespace oETCS { namespace DF { class CControlFlow; } }
75 namespace DSM { class CGOPPRRTransformer; }
76 namespace GOPPRR { class CConstraintChecker; }
77 namespace oETCS { namespace GEN { class CCPPGenerator; } }
78 
79 
80 namespace oETCS {
81 
82 namespace UT {
83 
84 
85 /*!
86  * \brief test class for ::oETS:DF::CFunctionBlock
87  */
88 class CFunctionBlock : public ::CppUnit::TestFixture
89 {
117 
118 
119  public:
120  /*!
121  * \brief default constructor
122  */
123  CFunctionBlock() throw();
124 
125 
126 
127  /*!
128  * \brief creates all test objects
129  */
130  void setUp() throw(::std::bad_alloc);
131 
132 
133 
134  /*!
135  * \brief delete all test objects
136  */
137  void tearDown() throw();
138 
139 
140 
141  /*!
142  * \brief test method for ::oETCS::DF:CAnd
143  */
144  void TestAnd() throw(::std::exception);
145 
146 
147 
148  /*!
149  * \brief test method for ::oETCS::DF:COr
150  */
151  void TestOr() throw(::std::exception);
152 
153 
154 
155  /*!
156  * \brief test method for ::oETCS::DF:CXor
157  */
158  void TestXor() throw(::std::exception);
159 
160 
161 
162  /*!
163  * \brief test method for ::oETCS::DF:CNot
164  */
165  void TestNot() throw(::std::exception);
166 
167 
168 
169  /*!
170  * \brief test method for ::oETCS::DF:CSum
171  */
172  void TestSum() throw(::std::exception);
173 
174 
175 
176  /*!
177  * \brief test method for ::oETCS::DF:CSubstraction
178  */
179  void TestSubstraction() throw(::std::exception);
180 
181 
182 
183  /*!
184  * \brief test method for ::oETCS::DF:CDivision
185  */
186  void TestDivision() throw(::std::exception);
187 
188 
189 
190  /*!
191  * \brief test method for ::oETCS::DF:CMultiplication
192  */
193  void TestMultiplication() throw(::std::exception);
194 
195 
196 
197  /*!
198  * \brief test method for ::oETCS::DF:CDoubleEqual
199  */
200  void TestDoubleEqual() throw(::std::exception);
201 
202 
203 
204  /*!
205  * \brief test method for ::oETCS::DF:CIntEqual
206  */
207  void TestIntEqual() throw(::std::exception);
208 
209 
210 
211  /*!
212  * \brief test method for ::oETCS::DF:CStringEqual
213  */
214  void TestStringEqual() throw(::std::exception);
215 
216 
217 
218  /*!
219  * \brief test method for ::oETCS::DF:CDoubleEqualOrGreater
220  */
221  void TestDoubleEqualOrGreater() throw(::std::exception);
222 
223 
224 
225  /*!
226  * \brief test method for ::oETCS::DF:CDoubleGreater
227  */
228  void TestDoubleGreater() throw(::std::exception);
229 
230 
231 
232  /*!
233  * \brief test method for ::oETCS::DF:CIntGreater
234  */
235  void TestIntGreater() throw(::std::exception);
236 
237 
238 
239  /*!
240  * \brief test method for ::oETCS::DF:CDoubleArrayAccessor
241  */
242  void TestDoubleArrayAccessor() throw(::std::exception);
243 
244 
245 
246  /*!
247  * \brief test method for ::oETCS::DF:CBoolGate
248  */
249  void TestBoolGate() throw(::std::exception);
250 
251 
252 
253  /*!
254  * \brief test method for ::oETCS::DF:CBrakingToTargetSpeed
255  */
256  void TestBrakingToTargetSpeed() throw(::std::exception);
257 
258 
259 
260  /*!
261  * \brief test method for ::oETCS::DF:CBrakingToTargetSpeed
262  */
263  void TestCeelingSpeedControl() throw(::std::exception);
264 
265 
266 
267  /*!
268  * \brief test method for ::oETCS::DF:CStringGate
269  */
270  void TestStringGate() throw(::std::exception);
271 
272 
273 
274  /*!
275  * \brief test method for ::oETCS::DF:CDoubleGate
276  */
277  void TestDoubleGate() throw(::std::exception);
278 
279 
280 
281  /*!
282  * \brief test method for ::oETCS::DF:CBoolSwitch
283  */
284  void TestBoolSwitch() throw(::std::exception);
285 
286 
287 
288  /*!
289  * \brief test method for ::oETCS::DF:CDoubleSwitch
290  */
291  void TestDoubleSwitch() throw(::std::exception);
292 
293 
294 
295  /*!
296  * \brief test method for ::oETCS::DF:CStringSwitch
297  */
298  void TestStringSwitch() throw(::std::exception);
299 
300 
301 
302  /*!
303  * \brief test method for ::oETCS::DF:CEnteredTrigger
304  */
305  void TestEnteredTrigger() throw(::std::exception);
306 
307 
308 
309  /*!
310  * \brief test method for ::oETCS::DF:CStorage
311  */
312  void TestStorage() throw(::std::exception);
313 
314 
315 
316 
317  private:
318  /*!
319  * \brief state machine used as reference for function block classes
320  */
322 
323 
324 
325  /*!
326  * \brief pointer to oETCS::DF::CAnd instance for testing
327  */
329 
330 
331 
332  /*!
333  * \brief pointer to oETCS::DF::COr instance for testing
334  */
336 
337 
338 
339  /*!
340  * \brief pointer to oETCS::DF::CEVCCondition instance for testing
341  */
343 
344 
345 
346  /*!
347  * \brief pointer to oETCS::DF::CCondition instance for testing
348  */
350 
351 
352 
353  /*!
354  * \brief pointer to oETCS::DF::CLevelCondition instance for testing
355  */
357 
358 
359 
360  /*!
361  * \brief pointer to oETCS::DF::CComBlockIn instance for testing
362  */
364 
365 
366 
367  /*!
368  * \brief pointer to oETCS::DF::CComBlockOut instance for testing
369  */
371 
372 
373 
374  /*!
375  * \brief pointer to oETCS::DF::CXor instance for testing
376  */
378 
379 
380 
381  /*!
382  * \brief pointer to oETCS::DF::CNot instance for testing
383  */
385 
386 
387 
388  /*!
389  * \brief pointer to oETCS::DF::CSum instance for testing
390  */
392 
393 
394 
395  /*!
396  * \brief pointer to oETCS::DF::CSubstraction instance for testing
397  */
399 
400 
401 
402  /*!
403  * \brief pointer to oETCS::DF::CDivision instance for testing
404  */
406 
407 
408 
409  /*!
410  * \brief pointer to oETCS::DF::CMultiplication instance for testing
411  */
413 
414 
415 
416  /*!
417  * \brief pointer to oETCS::DF::CDoubleEqual instance for testing
418  */
420 
421 
422 
423  /*!
424  * \brief pointer to oETCS::DF::COr instance for testing
425  */
427 
428 
429 
430  /*!
431  * \brief pointer to oETCS::DF::CStringEqual instance for testing
432  */
434 
435 
436 
437  /*!
438  * \brief pointer to oETCS::DF::CDoubleEqualOrGreater instance for testing
439  */
441 
442 
443 
444  /*!
445  * \brief pointer to oETCS::DF::CDoubleGreater instance for testing
446  */
448 
449 
450 
451  /*!
452  * \brief pointer to oETCS::DF::CIntGreater instance for testing
453  */
455 
456 
457 
458  /*!
459  * \brief pointer to oETCS::DF::CDoubleArrayAccessor instance for testing
460  */
462 
463 
464 
465  /*!
466  * \brief pointer to oETCS::DF::CBoolGate instance for testing
467  */
469 
470 
471 
472  /*!
473  * \brief pointer to oETCS::DF::CBrakingToTargetSpeed instance for testing
474  */
476 
477 
478 
479  /*!
480  * \brief pointer to oETCS::DF::CCeelingSpeedControl instance for testing
481  */
483 
484 
485 
486  /*!
487  * \brief pointer to oETCS::DF::CStringGate instance for testing
488  */
490 
491 
492 
493  /*!
494  * \brief pointer to oETCS::DF::CDoubleGate instance for testing
495  */
497 
498 
499 
500  /*!
501  * \brief pointer to oETCS::DF::CBoolSwitch instance for testing
502  */
504 
505 
506 
507  /*!
508  * \brief pointer to oETCS::DF::CDoubleSwitch instance for testing
509  */
511 
512 
513 
514  /*!
515  * \brief pointer to oETCS::DF::CStringSwitch instance for testing
516  */
518 
519 
520 
521  /*!
522  * \brief pointer to oETCS::DF::CEnteredTrigger instance for testing
523  */
525 
526 
527 
528  /*!
529  * \brief pointer to oETCS::DF::CStorage instance for testing
530  */
532 
533 
534 
535  /*!
536  * \brief pointer to oETCS::DF::CStorage instance for testing the bit data flow
537  */
539 
540 
541 
542 
543  public:
544  /*!
545  * \brief boolean input storage
546  */
548 
549 
550 
551  /*!
552  * \brief boolean input storage
553  */
555 
556 
557 
558  /*!
559  * \brief boolean input storage
560  */
562 
563 
564 
565  /*!
566  * \brief boolean input storage
567  */
569 
570 
571 
572  /*!
573  * \brief double input storage
574  */
576 
577 
578 
579  /*!
580  * \brief double array input storage
581  */
583 
584 
585 
586  /*!
587  * \brief integer input storage
588  */
590 
591 
592 
593  /*!
594  * \brief string input storage
595  */
597 
598 
599 
600 
601 }; // class CFunctionBlock : public ::CppUnit::TestFixture
602 
603 
604 
605 /*!
606  * \brief test class for ::oETCS::DF::CTelegram, ::oETCS::DF::CPacket and ::oETCS::DF::CVariable,
607  */
608 class CLanguage : public ::CppUnit::TestFixture
609 {
613 
614 
615  public:
616  /*!
617  * \brief default constructor
618  */
619  explicit CLanguage() throw();
620 
621 
622 
623  /*!
624  * \brief creates all test objects
625  */
626  void setUp() throw(::std::bad_alloc);
627 
628 
629 
630  /*!
631  * \brief delete all test objects
632  */
633  void tearDown() throw();
634 
635 
636 
637  /*!
638  * \brief test method for testing ::oETCS::DF::CTelegram
639  */
640  void TestTelegram() throw(::std::exception);
641 
642 
643 
644 
645  private:
646  /*!
647  * \brief EVC state machine object needed for instanciation of other objects
648  */
650 
651 
652 
653  /*!
654  * \brief pointer to telegram object for testing
655  */
657 
658 
659 
660  /*!
661  * \brief map of boolean input storages indexed by their literal name
662  */
663  ::std::map< ::std::string, oETCS::DF::BOOL_INPUT_T* > m_BoolInput;
664 
665 
666 
667  /*!
668  * \brief map of double input storages indexed by their literal name
669  */
670  ::std::map< ::std::string, oETCS::DF::DOUBLE_INPUT_T* > m_DoubleInput;
671 
672 
673 
674 
675  public:
676  /*!
677  * \brief map of double array input storages indexed by their literal name
678  */
679  ::std::map< ::std::string, oETCS::DF::DOUBLE_ARRAY_INPUT_T* > m_DoubleArrayInput;
680 
681 
682 
683  /*!
684  * \brief map of integer input storages indexed by their literal name
685  */
686  ::std::map< ::std::string, oETCS::DF::INT_INPUT_T* > m_IntInput;
687 
688 
689 
690  /*!
691  * \brief map of string input storages indexed by their literal name
692  */
693  ::std::map< ::std::string, oETCS::DF::STRING_INPUT_T* > m_StringInput;
694 
695 
696 
697 
698 }; // class CLanguage : public ::CppUnit::TestFixture
699 
700 
701 
702 /*!
703  * \brief test class for ::oETCS::DF::CStateMachine and ::oETCS::DF::CStateMachine::CEVCState
704  */
705 class CEVCStateMachine : public ::CppUnit::TestFixture
706 {
710 
711 
712  public:
713  /*!
714  * \brief default constructor
715  */
716  CEVCStateMachine() throw();
717 
718 
719 
720  /*!
721  * \brief creates all test objects
722  */
723  void setUp() throw(::std::bad_alloc);
724 
725 
726 
727  /*!
728  * \brief delete all test objects
729  */
730  void tearDown() throw();
731 
732 
733 
734  /*!
735  * \brief test method for testing ::oETCS::DF::CVCStateMachine::CEVCSTate
736  */
737  void TestEVCState() throw(::std::exception);
738 
739 
740 
741 
742  private:
743  /*!
744  * \brief pointer to EVC state machine, used as test object
745  */
747 
748 
749 
750 
751 }; // class CEVCStateMachine : public ::CppUnit::TestFixture
752 
753 
754 
755 /*!
756  * \brief test class for ::oETCS::DF::CControFlow and ::oETCS::DF::CControlFlow::CState
757  */
758 class CControlFlow : public ::CppUnit::TestFixture
759 {
763 
764 
765  public:
766  /*!
767  * \brief default constructor
768  */
769  CControlFlow() throw();
770 
771 
772 
773  /*!
774  * \brief creates all test objects
775  */
776  void setUp() throw(::std::bad_alloc);
777 
778 
779 
780  /*!
781  * \brief delete all test objects
782  */
783  void tearDown() throw();
784 
785 
786 
787  /*!
788  * \brief test method for testing ::oETCS::DF::CControlFlow::CState
789  */
790  void TestState() throw(::std::exception);
791 
792 
793 
794 
795  private:
796  /*!
797  * \brief boolean input storage
798  */
800 
801 
802 
803 
804  public:
805  /*!
806  * \brief string input storage
807  */
809 
810 
811 
812 
813  private:
814  /*!
815  * \brief pointer to EVC state machine, used as helper object for testing
816  */
818 
819 
820 
821  /*!
822  * \brief pointer to control flow, used as test object
823  */
825 
826 
827 
828 
829 }; // class CControlFlow : public ::CppUnit::TestFixture
830 
831 
832 
833 /*!
834  * \brief test class for ::DSM::CGOPPRRTransformer
835  */
836 class CGOPPRRTransformer : public ::CppUnit::TestFixture
837 {
842 
843 
844  public:
845  /*!
846  * \brief creates all test objects
847  */
848  void setUp() throw(::std::bad_alloc);
849 
850 
851 
852  /*!
853  * \brief delete all test objects
854  */
855  void tearDown() throw();
856 
857 
858 
859  /*!
860  * \brief test method for ::GOPPRR::CGOPPRRSyntaxLexer::CreateSyntax()
861  */
862  void TestCreateSyntax() throw(::std::exception);
863 
864 
865 
866  /*!
867  * \brief test method for testing the static semantics by ::GOPPRR::CConstraintChecker::Check()
868  */
869  void TestStaticSemantics() throw(::std::exception);
870 
871 
872 
873 
874  private:
875  /*!
876  * \brief pointer to GOPPRR syntax lexer object for testing
877  */
879 
880 
881 
882  /*!
883  * \brief pointer to the constraint checker test object
884  */
886 
887 
888 
889 
890 }; // class CGOPPRRTransformer : public ::CppUnit::TestFixture
891 
892 
893 
894 /*!
895  * \brief test class for ::oETCS::GEN::CGenerator sub-classes
896  */
897 class CGenerator : public ::CppUnit::TestFixture
898 {
902 
903 
904  public:
905  /*!
906  * \brief creates all test objects
907  */
908  void setUp() throw(::std::bad_alloc);
909 
910 
911 
912  /*!
913  * \brief delete all test objects
914  */
915  void tearDown() throw();
916 
917 
918 
919  /*!
920  * \brief test method for ::oETCS::GEN::CPPGenerator::Generate()
921  */
922  void TestGenerateCpp() throw(::std::exception);
923 
924 
925 
926 
927  private:
928  /*!
929  * \brief pointer to the C++ generator object used for testing
930  */
932 
933 
934 
935 
936 }; // class CGenerator : public ::CppUnit::TestFixture
937 
938 
939 
940 
941 
942 } // namespace oETCS::UT
943 
944 } // namespace oETCS
945 
946 #endif // __ OETCS_UT_UNITTESTING_H__

Copyright (C) 2010-2012 Johannes Feuser (feuser@uni-bremen.de)
The openETCS library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
The openETCS library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the openETCS library. If not, see "http://www.gnu.org/licenses/.