Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

TestCaseBasicDataPool_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseBasicDataPool_1.cpp 00005 // 00006 // Version 1.0 00007 // Date 13.10.03 00008 // Author A. Pasetti (P&P Software) 00009 00010 #include "../GeneralInclude/CompilerSwitches.h" 00011 #include "../GeneralInclude/ClassId.h" 00012 #include "../GeneralInclude/Constants.h" 00013 #include "../Data/DC_BasicDatabase.h" 00014 #include "../FDIR/RecoveryAction.h" 00015 #include "../FDIR/MonitoringProfile.h" 00016 #include "../Data/DC_BasicDataPool.h" 00017 #include "../Data/DC_DataItem.h" 00018 #include "TestCaseBasicDataPool_1.h" 00019 00020 #include <math.h> 00021 #include <float.h> 00022 00023 TestCaseBasicDataPool_1::TestCaseBasicDataPool_1(void) : 00024 TestCaseGenericSetUp(ID_BASICDATAPOOL*10+1,"TestCaseBasicDataPool_1") { 00025 return; 00026 } 00027 00028 void TestCaseBasicDataPool_1::runTestCase(void) { 00029 00030 // Data to be written and read back from the data pool together with their identifiers. 00031 TD_Float f = (TD_Float)2.0; 00032 TD_Integer i = (TD_Integer)3; 00033 TD_DataPoolId f_id = 0; 00034 TD_DataPoolId i_id = sizeof(TD_Float); 00035 00036 // Instantiate basic datapool 00037 DC_BasicDataPool* pDP = new DC_BasicDataPool(); 00038 00039 // Verify correctness of class ID 00040 if (pDP->getClassId() != ID_BASICDATAPOOL) 00041 { setTestResult(TEST_FAILURE, "Wrong class ID"); 00042 return; 00043 } 00044 00045 // Check that datapool is not yet configured 00046 if ( pDP->isObjectConfigured() != NOT_CONFIGURED ) 00047 { setTestResult(TEST_FAILURE, "Incorrect configuration status at creation"); 00048 return; 00049 } 00050 00051 // Set data pool size and check correctness 00052 TD_DataPoolId size = sizeof(TD_Integer)+sizeof(TD_Float); 00053 pDP->setDataPoolSize(size); 00054 if ( pDP->getDataPoolSize() != size ) 00055 { setTestResult(TEST_FAILURE, "Incorrect value for the data pool size"); 00056 return; 00057 } 00058 00059 // Check that database is configured 00060 if ( pDP->isObjectConfigured() != CONFIGURED ) 00061 { setTestResult(TEST_FAILURE, "Incorrect configuration status after configuration was completed"); 00062 return; 00063 } 00064 00065 // Check retrieval of data item attribute 00066 DC_DataItem* pDI = pDP->getDataItem(3); 00067 if ( pDI->getIntegerValue() != 0 ) 00068 { setTestResult(TEST_FAILURE, "Incorrect data item attribute"); 00069 return; 00070 } 00071 00072 // Check retrieval of time stamp attribute 00073 if ( pDP->getTimeStamp(2) != 0 ) 00074 { setTestResult(TEST_FAILURE, "Incorrect time stamp attribute"); 00075 return; 00076 } 00077 00078 // Check retrieval of validity attribute 00079 if ( !pDP->isValid(2) ) 00080 { setTestResult(TEST_FAILURE, "Incorrect validity attribute"); 00081 return; 00082 } 00083 00084 // Check type checking services 00085 if ( (!pDP->isFloat(7)) || (!pDP->isInteger(7)) ) 00086 { setTestResult(TEST_FAILURE, "Incorrect type checking services"); 00087 return; 00088 } 00089 00090 // Check iteration methods 00091 if ( (pDP->firstIdentifier()!=0) || (pDP->nextIdentifier()!=0) || (!pDP->isLastIdentifier()) ) 00092 { setTestResult(TEST_FAILURE, "Incorrect iteration services"); 00093 return; 00094 } 00095 00096 // Check retrieval of monitoring profile attribute 00097 if ( pDP->getMonitoringProfile(2)->getClassId() != ID_NULLPROFILE ) 00098 { setTestResult(TEST_FAILURE, "Incorrect monitoring profile attribute"); 00099 return; 00100 } 00101 00102 // Check retrieval of recovery action attribute 00103 if ( pDP->getRecoveryAction(3)->getClassId() != ID_NULLRECOVERYACTION ) 00104 { setTestResult(TEST_FAILURE, "Incorrect monitoring profile attribute"); 00105 return; 00106 } 00107 00108 // Call reset and validity setter methods (just to show that they can be called without 00109 // crashing the system) 00110 pDP->reset(); 00111 pDP->setValidityStatus(0,true); 00112 00113 // Set and read float value and check correctness 00114 pDP->setValue(f_id,f); 00115 if (fabs(pDP->getFloatValue(f_id)-f)>FLT_EPSILON) 00116 { setTestResult(TEST_FAILURE, "Incorrect write/read cycle for float value"); 00117 return; 00118 } 00119 00120 // Set and read integer value and check correctness 00121 pDP->setValue(i_id,i); 00122 if (pDP->getIntegerValue(i_id)!=i) 00123 { setTestResult(TEST_FAILURE, "Incorrect write/read cycle for integer value"); 00124 return; 00125 } 00126 00127 // Check pointer access for float values 00128 if (fabs( (float) ((*(pDP->getPointerFloatValue(f_id)))-f) )>FLT_EPSILON) 00129 { setTestResult(TEST_FAILURE, "Incorrect pointer access to float value"); 00130 return; 00131 } 00132 00133 // Check pointer access for integer values 00134 if ( (*(pDP->getPointerIntegerValue(i_id)))!=i ) 00135 { setTestResult(TEST_FAILURE, "Incorrect pointer access to integer value"); 00136 return; 00137 } 00138 00139 setTestResult(TEST_SUCCESS,"Test Successful"); 00140 return; 00141 }
Copyright 2003 P&P Software GmbH - All Rights Reserved