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

TestCaseIntStack_1.cpp

00001 00002 00003 // 00004 // Copyright 2003 P&P Software GmbH - All Rights Reserved 00005 // 00006 // TestCaseIntStack_1.h 00007 // 00008 // Version 1.0 00009 // Date 10.09.03 (Version 1.0) 00010 // Author A. Pasetti (P&P Software) 00011 // 00012 00013 #include "../GeneralInclude/CompilerSwitches.h" 00014 #include "../GeneralInclude/ClassId.h" 00015 #include "../GeneralInclude/Constants.h" 00016 #include "../System/CC_IntStack.h" 00017 #include "TestCaseIntStack_1.h" 00018 #include "../Utilities/TestCaseWithEvtCheck.h" 00019 00020 #include <math.h> 00021 #include <float.h> 00022 00023 TestCaseIntStack_1::TestCaseIntStack_1(): 00024 TestCaseWithEvtCheck(ID_INTSTACK*10+1,"TestCaseIntStack_1") { 00025 return; 00026 } 00027 00028 void TestCaseIntStack_1::runTestCase() { 00029 CC_IntStack* pStack = new CC_IntStack(); 00030 unsigned int size = 2; 00031 unsigned int nEvt = getNumberOfEvents(); 00032 int pItem1 = (int)1; 00033 00034 // Check the value of the class identifier 00035 if ( pStack->getClassId() != ID_INTSTACK ) 00036 { setTestResult(TEST_FAILURE, "Wrong class identifier"); 00037 return; 00038 } 00039 00040 // Check configuration status 00041 if ( pStack->isObjectConfigured() ) 00042 { setTestResult(TEST_FAILURE, "Wrong configuration status"); 00043 return; 00044 } 00045 00046 // Set the stack size 00047 pStack->setStackSize(size); 00048 if ( pStack->getStackSize() != size) 00049 { setTestResult(TEST_FAILURE, "Wrong stack size value"); 00050 return; 00051 } 00052 00053 // Check configuration status 00054 if ( !pStack->isObjectConfigured() ) 00055 { setTestResult(TEST_FAILURE, "Wrong configuration status"); 00056 return; 00057 } 00058 00059 // Push one item on stack and check correctness 00060 pStack->push(pItem1); 00061 if ( pStack->getNumberOfItems() != 1 ) 00062 { setTestResult(TEST_FAILURE, "Wrong number of items on stack"); 00063 return; 00064 } 00065 00066 if ( fabs((float)(pStack->pop()-pItem1))>FLT_EPSILON ) 00067 { setTestResult(TEST_FAILURE, "Wrong item on stack"); 00068 return; 00069 } 00070 00071 // Check that a pop operation returns pNULL and generates correct event 00072 if ( pStack->pop() != pNULL ) 00073 { setTestResult(TEST_FAILURE, "Wrong item on stack"); 00074 return; 00075 } 00076 if ( !verifyLatestEvent(nEvt+1,EVT_STACK_EMPTY) ) 00077 { setTestResult(TEST_FAILURE, "Wrong event"); 00078 return; 00079 } 00080 00081 // Perform three push operations and verify event generation 00082 pStack->push(pItem1); 00083 pStack->push(pItem1); 00084 if ( !pStack->isFull() ) 00085 { setTestResult(TEST_FAILURE, "Stack should be full"); 00086 return; 00087 } 00088 pStack->push(pItem1); 00089 if ( !verifyLatestEvent(nEvt+2,EVT_STACK_FULL) ) 00090 { setTestResult(TEST_FAILURE, "Wrong event"); 00091 return; 00092 } 00093 00094 // Check that there are only two items on the stack 00095 if ( pStack->getNumberOfItems()!=2 ) 00096 { setTestResult(TEST_FAILURE, "wrong number of items in stack"); 00097 return; 00098 } 00099 00100 // Perform a stack reset and check success 00101 pStack->reset(); 00102 if ( pStack->getNumberOfItems() != 0 ) 00103 { setTestResult(TEST_FAILURE, "Reset operation failed"); 00104 return; 00105 } 00106 if ( !pStack->isEmpty() ) 00107 { setTestResult(TEST_FAILURE, "Reset operation failed"); 00108 return; 00109 } 00110 00111 setTestResult(TEST_SUCCESS,"Test Successful"); 00112 return; 00113 00114 }
Copyright 2003 P&P Software GmbH - All Rights Reserved