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

TestCaseManoeuvreManager_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseManoeuvreManager_1.cpp 00005 // 00006 // Version 1.0 00007 // Date 08.05.03 00008 // Author R. Totaro 00009 00010 #include "TestCaseManoeuvreManager_1.h" 00011 #include "../GeneralInclude/ClassId.h" 00012 #include "../GeneralInclude/Constants.h" 00013 #include "../GeneralInclude/CompilerSwitches.h" 00014 #include "../Manoeuvre/CC_ManoeuvreManager.h" 00015 #include "../Manoeuvre/DC_DummyManoeuvre.h" 00016 00017 TestCaseManoeuvreManager_1::TestCaseManoeuvreManager_1(void) : 00018 TestCaseWithEvtCheck(ID_MANOEUVREMANAGER*10+1,"TestCaseManoeuvreManager_1") { 00019 return; 00020 } 00021 00022 void TestCaseManoeuvreManager_1::runTestCase(void) { 00023 CC_ManoeuvreManager *pMM =new CC_ManoeuvreManager(); 00024 const unsigned int nEvt=getNumberOfEvents(); 00025 const unsigned int nMan=8; 00026 00027 // Verify correctness of class identifier 00028 if (pMM->getClassId()!=ID_MANOEUVREMANAGER) { 00029 setTestResult(TEST_FAILURE,"Wrong class identifier"); 00030 return; 00031 } 00032 00033 // A newly created ManoeuvreManager shall not be configured 00034 if (pMM->isObjectConfigured()) { 00035 setTestResult(TEST_FAILURE,"Newly created ManoeuvreManager already configured"); 00036 return; 00037 } 00038 00039 // Configure the ManoeuvreManager and verify the operation 00040 pMM->setPendingManoeuvreListSize(nMan); 00041 if (pMM->getPendingManoeuvreListSize()!=nMan) { 00042 setTestResult(TEST_FAILURE,"Wrong getPendingManoeuvreListSize return value"); 00043 return; 00044 } 00045 00046 // Now it should be configured 00047 if (!pMM->isObjectConfigured()) { 00048 setTestResult(TEST_FAILURE,"ManoeuvreManager not configured"); 00049 return; 00050 } 00051 00052 // Clearly, there shall be no pending manoeuvres 00053 if (pMM->getPendingManoeuvres()!=0) { 00054 setTestResult(TEST_FAILURE,"Wrong getPendingManoeuvres return value"); 00055 return; 00056 } 00057 00058 // The following steps check the load(), unload() and abort() methods. 00059 // Let's create an array of DC_DummyManoeuvre pointers to be used in the 00060 // subsequent tests. 00061 DC_DummyManoeuvre *pDM[nMan+1]; 00062 00063 for (unsigned int i=0; i<=nMan; i++) 00064 pDM[i]=new DC_DummyManoeuvre(); 00065 00066 for (unsigned int i=0;i<nMan;i++) { 00067 // Load the manouvre 00068 pMM->load(pDM[i]); 00069 00070 // Verify that manCounter is incremented 00071 if (pMM->getPendingManoeuvres()!=(i+1)) { 00072 setTestResult(TEST_FAILURE,"manCounter was not incremented"); 00073 return; 00074 } 00075 00076 // Set the "in use" flag 00077 pDM[i]->setInUse(true); 00078 } 00079 00080 // A manoeuvre is aborted and the effect of the operation verified 00081 pMM->abort(pDM[nMan-1]); 00082 if (pMM->getPendingManoeuvres()!=(nMan-1)) { 00083 setTestResult(TEST_FAILURE,"manCounter was not decremented"); 00084 return; 00085 } 00086 00087 // Check that the manouvre is no longer in use 00088 if (pDM[nMan-1]->isInUse()) { 00089 setTestResult(TEST_FAILURE,"Aborted manoeuvre still in use"); 00090 return; 00091 } 00092 00093 // Load the previously aborted manoeuvre 00094 pMM->load(pDM[nMan-1]); 00095 00096 // Try loading more manoeuvres that the allocated space and verify 00097 // that the event is reported. 00098 pMM->load(pDM[nMan]); 00099 if (!verifyLatestEvent((nEvt+nMan+3),EVT_MAN_LIST_FULL)) 00100 return; 00101 00102 // Finally, let's reset the manoeuvre manager and verify that all 00103 // the pending manoeuvres are aborted. 00104 pMM->reset(); 00105 for (int i=0;i<nMan;i++) { 00106 if (pDM[i]->isInUse()) { 00107 setTestResult(TEST_FAILURE,"Reset failed to abort a manoeuvre"); 00108 return; 00109 } 00110 } 00111 00112 setTestResult(TEST_SUCCESS,"Test Successful"); 00113 return; 00114 }
Copyright 2003 P&P Software GmbH - All Rights Reserved