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

TestCaseProfileList_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseProfileList_1.cpp 00005 // 00006 // Version 1.3 00007 // Date 15.09.03 (Version 1.0) 00008 // 01.10.03 (Version 1.1) 00009 // 08.10.03 (Version 1.2) 00010 // 21.10.03 (Version 1.3) 00011 // Author R. Totaro 00012 // 00013 // Change Record: 00014 // Version 1.1: Replaced double and int with TD_Float and TD_Integer 00015 // Version 1.2: Added check that isObjectConfigured() works according to specs 00016 // Version 1.3: Replaced all occurrences of loadMonitoringProfile() with setMonitoringProfile() 00017 00018 #include "../GeneralInclude/CompilerSwitches.h" 00019 #include "../GeneralInclude/ClassId.h" 00020 #include "../GeneralInclude/Constants.h" 00021 #include "../FDIR/DC_InRangeProfile.h" 00022 #include "../FDIR/DC_ProfileList.h" 00023 #include "TestCaseProfileList_1.h" 00024 00025 TestCaseProfileList_1::TestCaseProfileList_1(void) : 00026 TestCaseWithEvtCheck(ID_PROFILELIST*10+1,"TestCaseProfileList_1") { 00027 return; 00028 } 00029 00030 void TestCaseProfileList_1::runTestCase(void) { 00031 DC_ProfileList *pPL =new DC_ProfileList; 00032 const unsigned int nEvt =getNumberOfEvents(); 00033 const unsigned int listSize =2; 00034 const TD_Float rangeWidth=5.0; 00035 DC_InRangeProfile *pIRP[listSize]; 00036 00037 // Create and initialize the monitoring profiles we are using to 00038 // test the DC_ProfileList class. 00039 for (unsigned int i=0;i<listSize;i++) { 00040 pIRP[i]=new DC_InRangeProfile; 00041 pIRP[i]->setLowerBound((TD_Float)i); 00042 pIRP[i]->setUpperBound((TD_Float)i+rangeWidth); 00043 } 00044 00045 // Verify the correctness of the class id 00046 if (pPL->getClassId()!=ID_PROFILELIST) { 00047 setTestResult(TEST_FAILURE,"Wrong class identifier"); 00048 return; 00049 } 00050 00051 // A new object shall not be configured 00052 if (pPL->isObjectConfigured()) { 00053 setTestResult(TEST_FAILURE,"Newly created object already configured"); 00054 return; 00055 } 00056 00057 // Set the list size and verify it is reported correctly 00058 pPL->setListSize(listSize); 00059 if (pPL->getListSize()!=listSize) { 00060 setTestResult(TEST_FAILURE,"getListSize() failed"); 00061 return; 00062 } 00063 00064 // Load and get the monitoring profiles 00065 for (unsigned int i=0;i<listSize;i++) { 00066 // The object is fully configured only when all the profiles are loaded! 00067 if (pPL->isObjectConfigured()) { 00068 setTestResult(TEST_FAILURE,"Wrong configuration status"); 00069 return; 00070 } 00071 00072 pPL->setMonitoringProfile(i,pIRP[i]); 00073 00074 if (pPL->getMonitoringProfile(i)!=pIRP[i]) { 00075 setTestResult(TEST_FAILURE,"setMonitoringProfile() failed"); 00076 return; 00077 } 00078 } 00079 00080 // Only now it is configured. Let's check it. 00081 if (!pPL->isObjectConfigured()) { 00082 setTestResult(TEST_FAILURE,"Object not configured"); 00083 return; 00084 } 00085 00086 // Verify that setMonitoringProfile() generates an error report 00087 // when invoked with an invalid index 00088 if (isNonNominalCheckAllowed()) { 00089 pPL->setMonitoringProfile(listSize,pIRP[0]); 00090 if (!verifyLatestEvent(nEvt+1,EVT_ILLEGAL_MP)) 00091 return; 00092 } 00093 00094 // These profile checks shall not fail 00095 if (pPL->deviatesFromProfile((TD_Integer)-1)) { 00096 setTestResult(TEST_FAILURE,"doProfileCheck(TD_Integer): unexpected failure"); 00097 return; 00098 } 00099 00100 if (pPL->deviatesFromProfile((TD_Float)-1.0)) { 00101 setTestResult(TEST_FAILURE,"doProfileCheck(TD_Float): unexpected failure"); 00102 return; 00103 } 00104 00105 // These profile checks shall fail 00106 if (!pPL->deviatesFromProfile((TD_Integer)1)) { 00107 setTestResult(TEST_FAILURE,"doProfileCheck(TD_Integer): unexpected success"); 00108 return; 00109 } 00110 00111 if (!pPL->deviatesFromProfile((TD_Float)1.0)) { 00112 setTestResult(TEST_FAILURE,"doProfileCheck(TD_Float): unexpected success"); 00113 return; 00114 } 00115 00116 if (!pPL->deviatesFromProfile((TD_Integer)(listSize+rangeWidth-2))) { 00117 setTestResult(TEST_FAILURE,"doProfileCheck(TD_Integer): unexpected success"); 00118 return; 00119 } 00120 00121 if (!pPL->deviatesFromProfile((TD_Float)(listSize+rangeWidth-2.0))) { 00122 setTestResult(TEST_FAILURE,"doProfileCheck(TD_Float): unexpected success"); 00123 return; 00124 } 00125 00126 setTestResult(TEST_SUCCESS,"Test Successful"); 00127 return; 00128 }
Copyright 2003 P&P Software GmbH - All Rights Reserved