00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <mpcl/invariant/verifier.hh>
00027 #include <mpcl/test.h>
00028
00029
00030 using mpcl::invariant::IVerifier;
00031
00032
00033 class TVerifier : public IVerifier<int>
00034 {
00035
00036 public:
00037
00038 enum { FIRST_LEVEL, SECOND_LEVEL, THIRD_LEVEL };
00039 enum { FIRST_RULE, SECOND_RULE, THIRD_RULE, FOURTH_RULE };
00040
00041
00042 public:
00043
00044
00045
00046
00047
00049 TVerifier (void) :
00050 IVerifier<int> (FIRST_LEVEL) {}
00051
00052
00053 public:
00054
00055
00056
00057
00058
00065 bool verify (long int liINVARIANT_IDENTIFIER) const;
00066
00067 };
00068
00069
00070 bool TVerifier::verify (long int liINVARIANT_IDENTIFIER) const
00071 {
00072
00073 bool gSuccess = false;
00074
00075 switch (liINVARIANT_IDENTIFIER)
00076 {
00077 case FIRST_RULE:
00078 {
00079 gSuccess = ( tArgumentArray [0] < 1000 );
00080 break;
00081 }
00082 case SECOND_RULE:
00083 {
00084 gSuccess = ( tArgumentArray [0] < 100 );
00085 break;
00086 }
00087 case THIRD_RULE:
00088 {
00089 gSuccess = ( tArgumentArray [0] < 10 );
00090 break;
00091 }
00092 case FOURTH_RULE:
00093 {
00094 gSuccess = ( tArgumentArray [0] < 1 );
00095 break;
00096 }
00097 }
00098 return gSuccess;
00099
00100 }
00101
00102
00104 int main (void)
00105 {
00106
00107 TEST_INIT ("tests for class 'IVerifier'");
00108
00109 TVerifier tRV;
00110
00111 tRV.tConformanceLevelSet.insert (TVerifier::FIRST_LEVEL);
00112 tRV.tConformanceLevelSet.insert (TVerifier::SECOND_LEVEL);
00113 tRV.tConformanceLevelSet.insert (TVerifier::THIRD_LEVEL);
00114
00115 tRV.addInvariant (TVerifier::FIRST_RULE, TVerifier::FIRST_LEVEL, "Less than 1000");
00116 tRV.addInvariant (TVerifier::SECOND_RULE, TVerifier::FIRST_LEVEL, "Less than 100");
00117 tRV.addInvariant (TVerifier::THIRD_RULE, TVerifier::SECOND_LEVEL, "Less than 10");
00118 tRV.addInvariant (TVerifier::FOURTH_RULE, TVerifier::THIRD_LEVEL, "Less than 1");
00119
00120 tRV.require (TVerifier::FIRST_RULE, 999);
00121
00122 tRV.tConformanceLevelSet.erase (TVerifier::FIRST_LEVEL);
00123 tRV.require (TVerifier::FIRST_RULE, 1000);
00124 tRV.require (TVerifier::SECOND_RULE, 1000);
00125 tRV.require (TVerifier::THIRD_RULE, 9);
00126
00127 TEST_MEMORY_STATUS;
00128 TEST_RETURN_CODE;
00129
00130 }