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

TestCaseEventRepository_2.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseEventRepository_2.cpp 00005 // 00006 // Version 1.1 00007 // Date 25.02.03 00008 // Author A. Pasetti (P&P Software) 00009 00010 #include "TestCaseEventRepository_2.h" 00011 #include "../GeneralInclude/CompilerSwitches.h" 00012 #include "../GeneralInclude/ClassId.h" 00013 #include "../GeneralInclude/Constants.h" 00014 #include "../Base/CC_RootObject.h" 00015 #include "../System/DC_DummyObsClock.h" 00016 #include "../Event/DC_EventRepository.h" 00017 #include "../Event/DC_Event.h" 00018 00019 TestCaseEventRepository_2::TestCaseEventRepository_2(void) : 00020 TestCaseGenericSetUp(ID_EVENTREPOSITORY*10+2,"TestCaseEventRepository_2") { 00021 return; 00022 } 00023 00024 void TestCaseEventRepository_2::runTestCase(void) { 00025 00026 DC_EventRepository* pRep = new DC_EventRepository(); 00027 00028 TD_EventType type1 = (TD_EventType)1; 00029 TD_EventType type2 = (TD_EventType)2; 00030 TD_EventType type3 = (TD_EventType)3; 00031 00032 // Configure the event repository: load OBS clock and set repository size 00033 unsigned int size = 4; 00034 DC_DummyObsClock* pClk = new DC_DummyObsClock(); 00035 pRep->setObsClock(pClk); 00036 pRep->setRepositorySize(size); 00037 00038 // Check correct configuration 00039 if ( (pRep->isObjectConfigured() == NOT_CONFIGURED) ) 00040 { setTestResult(TEST_FAILURE, 00041 "Wrong event repository configuration status after configuration"); 00042 return; 00043 } 00044 00045 // Create two events in the repository 00046 pClk->setTime(1); 00047 pClk->setCycle(1); 00048 pRep->create(pRep,type1); 00049 pClk->setTime(2); 00050 pClk->setCycle(1); 00051 pRep->create(pRep,type2); 00052 00053 // Check value of event counter 00054 if ( (pRep->getCounter() != 2) ) 00055 { setTestResult(TEST_FAILURE,"Wrong number of events in event repository"); 00056 return; 00057 } 00058 00059 // Iterate through the events in the repository and verify their types 00060 pRep->latest(); // position event pointer on latest event 00061 if ( pRep->getEventType() != type2 ) 00062 { setTestResult(TEST_FAILURE, 00063 "Wrong event type for latest event"); 00064 return; 00065 } 00066 00067 if (pRep->getTimeStamp()!=2) { 00068 setTestResult(TEST_FAILURE,"getTimeStamp() failed"); 00069 return; 00070 } 00071 00072 pRep->previous(); 00073 if ( pRep->isIterationFinished() ) 00074 { setTestResult(TEST_FAILURE, 00075 "Error in repository iteration service"); 00076 return; 00077 } 00078 00079 if ( pRep->getEventType() != type1 ) 00080 { setTestResult(TEST_FAILURE, 00081 "Wrong event type for first event"); 00082 return; 00083 } 00084 00085 if (pRep->getTimeStamp()!=1) { 00086 setTestResult(TEST_FAILURE,"getTimeStamp() failed"); 00087 return; 00088 } 00089 00090 pRep->previous(); 00091 if ( !(pRep->isIterationFinished()) ) 00092 { setTestResult(TEST_FAILURE, 00093 "Error in repository iteration service"); 00094 return; 00095 } 00096 00097 // Add events to the repository until one is overwritten 00098 unsigned int loopCounter = 0; 00099 for (unsigned int i=pRep->getCounter(); i<pRep->getRepositorySize()+1; i++) { 00100 pRep->create(pRep,(TD_EventType)(type3+loopCounter)); 00101 loopCounter++; 00102 } 00103 00104 // Check value of event counter 00105 if ( ( pRep->getCounter() != pRep->getRepositorySize()+1 ) ) 00106 { setTestResult(TEST_FAILURE,"Wrong number of events in event repository"); 00107 return; 00108 } 00109 00110 // Check correctness of latest event 00111 pRep->latest(); // position event pointer on latest event 00112 if ( pRep->getEventType() != (TD_EventType)(type3+loopCounter-1) ) 00113 { setTestResult(TEST_FAILURE, 00114 "Wrong event type for latest event"); 00115 return; 00116 } 00117 00118 // Iterate through the events in the repository and check that iteration 00119 // service returns a number of events equal to the repository size 00120 unsigned int counter = 0; 00121 for (pRep->latest(); !pRep->isIterationFinished(); pRep->previous()) 00122 counter++; 00123 if ( counter != pRep->getRepositorySize() ) 00124 { setTestResult(TEST_FAILURE, 00125 "Wrong number of events in repository"); 00126 return; 00127 } 00128 00129 // Verify that reset doesn't clear the event counter 00130 counter=pRep->getCounter(); 00131 pRep->reset(); 00132 if (counter!=pRep->getCounter()) { 00133 setTestResult(TEST_FAILURE,"Reset failed"); 00134 return; 00135 } 00136 00137 setTestResult(TEST_SUCCESS,"Test Successful"); 00138 return; 00139 }
Copyright 2003 P&P Software GmbH - All Rights Reserved