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

TestCaseControlAction_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseControlAction_1.cpp 00005 // 00006 // Version 1.0 00007 // Date 16.10.03 (Version 1.3) 00008 // Author A. Pasetti, R. Totaro 00009 // 00010 // Change Record: 00011 00012 #include "../Data/ControlBlock.h" 00013 #include "TestCaseControlAction_1.h" 00014 #include "../GeneralInclude/CompilerSwitches.h" 00015 #include "../GeneralInclude/ClassId.h" 00016 #include "../GeneralInclude/Constants.h" 00017 #include "../Data/DC_ControlAction.h" 00018 #include "../Data/DC_DummyCopyControlBlock.h" 00019 00020 00021 TestCaseControlAction_1::TestCaseControlAction_1(void) : 00022 TestCaseGenericSetUp(ID_CONTROLACTION*10+1, 00023 "TestCaseControlAction_1") { 00024 } 00025 00026 void TestCaseControlAction_1::runTestCase(void) { 00027 DC_ControlAction *pAct=new DC_ControlAction; 00028 00029 // Verify correctness of the class identifier 00030 if (pAct->getClassId()!=ID_CONTROLACTION) { 00031 setTestResult(TEST_FAILURE,"Wrong class identifier"); 00032 return; 00033 } 00034 00035 // Check that component is not configured 00036 if (pAct->isObjectConfigured()) { 00037 setTestResult(TEST_FAILURE,"Wrong configuration status"); 00038 return; 00039 } 00040 00041 // Create and configure a dummy control block 00042 DC_DummyCopyControlBlock *pDCB =new DC_DummyCopyControlBlock; 00043 const unsigned int numInputs =3; 00044 const TD_Float inputValues[]={(TD_Float)0.3,(TD_Float)0.04,(TD_Float)0.05}; 00045 00046 // Set control block inputs 00047 for (int i=0;i<numInputs;i++) 00048 pDCB->setInput(i,inputValues[i]); 00049 00050 // Load the control block and check success of load operations 00051 pAct->setTargetControlBlock(pDCB); 00052 if (pAct->getTargetControlBlock()!=pDCB) { 00053 setTestResult(TEST_FAILURE,"Loaded control block is wrong"); 00054 return; 00055 } 00056 00057 // Check that component is configured 00058 if (!pAct->isObjectConfigured()) { 00059 setTestResult(TEST_FAILURE,"Wrong configuration status"); 00060 return; 00061 } 00062 00063 // Check the execution request (as a result of an execution request 00064 // the value of the first element of the state should change) 00065 TD_Float initialState=pDCB->getState(0); 00066 00067 pAct->execute(); 00068 if (pDCB->getState(0)==initialState) { 00069 setTestResult(TEST_FAILURE,"Execution request failure"); 00070 return; 00071 } 00072 00073 // Check the reset request (as a result of a reset request, the 00074 // value of the first element of the state should go back to its 00075 // old value 00076 pAct->reset(); 00077 if (pDCB->getState(0)!=initialState) { 00078 setTestResult(TEST_FAILURE,"Reset request failure"); 00079 return; 00080 } 00081 00082 setTestResult(TEST_SUCCESS,"Test Successful"); 00083 return; 00084 }
Copyright 2003 P&P Software GmbH - All Rights Reserved