00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
#include "../GeneralInclude/CompilerSwitches.h"
00014
#include "../GeneralInclude/ClassId.h"
00015
#include "../GeneralInclude/Constants.h"
00016
#include "../System/CC_RootObjectStack.h"
00017
#include "TestCaseRootObjectStack_1.h"
00018
#include "../Utilities/TestCaseWithEvtCheck.h"
00019
00020
#include <math.h>
00021
#include <float.h>
00022
00023 TestCaseRootObjectStack_1::TestCaseRootObjectStack_1():
00024
TestCaseWithEvtCheck(ID_ROOTOBJECTSTACK*10+1,"
TestCaseRootObjectStack_1") {
00025
return;
00026 }
00027
00028 void TestCaseRootObjectStack_1::runTestCase() {
00029
CC_RootObjectStack* pStack =
new CC_RootObjectStack();
00030
unsigned int size = 2;
00031
unsigned int nEvt =
getNumberOfEvents();
00032
CC_RootObject* pItem1 =
new CC_RootObject();
00033
00034
00035
if ( pStack->
getClassId() != ID_ROOTOBJECTSTACK )
00036 { setTestResult(
TEST_FAILURE,
"Wrong class identifier");
00037
return;
00038 }
00039
00040
00041
if ( pStack->
isObjectConfigured() )
00042 { setTestResult(
TEST_FAILURE,
"Wrong configuration status");
00043
return;
00044 }
00045
00046
00047 pStack->
setStackSize(size);
00048
if ( pStack->
getStackSize() != size)
00049 { setTestResult(
TEST_FAILURE,
"Wrong stack size value");
00050
return;
00051 }
00052
00053
00054
if ( !pStack->
isObjectConfigured() )
00055 { setTestResult(
TEST_FAILURE,
"Wrong configuration status");
00056
return;
00057 }
00058
00059
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 ( pStack->
pop() != pItem1 )
00067 { setTestResult(
TEST_FAILURE,
"Wrong item on stack");
00068
return;
00069 }
00070
00071
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
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
00095
if ( pStack->
getNumberOfItems()!=2 )
00096 { setTestResult(
TEST_FAILURE,
"wrong number of items in stack");
00097
return;
00098 }
00099
00100
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 }