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

TestCaseCycleDataItem16TmStream_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseCycleDataItem16TmStream_1.cpp 00005 // 00006 // Version 1.1 00007 // Date 18.04.03 00008 // Author A. Pasetti (P&P Software) 00009 00010 #include "../GeneralInclude/CompilerSwitches.h" 00011 #include "../GeneralInclude/ClassId.h" 00012 #include "../GeneralInclude/TestConstants.h" 00013 #include "../Telemetry/DC_CycleDataItem16TmStream.h" 00014 #include "../Telemetry/DC_DummyTelemetryPacket.h" 00015 #include "../Data/DC_DataItem.h" 00016 #include "../Data/DC_RawDataItem.h" 00017 #include "TestCaseCycleDataItem16TmStream_1.h" 00018 00019 TestCaseCycleDataItem16TmStream_1::TestCaseCycleDataItem16TmStream_1(void) : 00020 TestCaseGenericSetUp(ID_CYCLEDATAITEM16TMSTREAM*10+1,"TestCaseCycleDataItem16TmStream_1") { 00021 return; 00022 } 00023 00024 void TestCaseCycleDataItem16TmStream_1::runTestCase(void) { 00025 00026 // Create three data item components 00027 unsigned short var1, var2, var3; 00028 DC_RawDataItem* pd1 = new DC_RawDataItem( &var1 ); 00029 DC_RawDataItem* pd2 = new DC_RawDataItem( &var2 ); 00030 DC_RawDataItem* pd3 = new DC_RawDataItem( &var3 ); 00031 00032 // Create and configure the dummy telemetry data item 00033 unsigned char d1 = 1; 00034 unsigned char d2 = 2; 00035 unsigned char d3 = 3; 00036 unsigned char d4 = 4; 00037 DC_DummyTelemetryPacket* pTW1 = new DC_DummyTelemetryPacket(); 00038 pTW1->setNumberOfBytes(4); 00039 pTW1->setValue(0,d1); 00040 pTW1->setValue(1,d2); 00041 pTW1->setValue(2,d3); 00042 pTW1->setValue(3,d4); 00043 00044 // Create the CycleDataItem16TmStream_1 component 00045 DC_CycleDataItem16TmStream* pTmStream = new DC_CycleDataItem16TmStream(); 00046 00047 // Check the value of the class identifier 00048 if ( pTmStream->getClassId() != ID_CYCLEDATAITEM16TMSTREAM ) 00049 { setTestResult(TEST_FAILURE, "Wrong class identifier"); 00050 return; 00051 } 00052 00053 // Check that the telemetry stream is not configured 00054 if ( pTmStream->isObjectConfigured() ) 00055 { setTestResult(TEST_FAILURE, "Wrong object configuration status"); 00056 return; 00057 } 00058 00059 // Set the size of the telemetry stream and verify correctness 00060 pTmStream->setNumberOfDataItems(3); 00061 if ( pTmStream->getCapacity() != 3 ) 00062 { setTestResult(TEST_FAILURE, "Wrong telemetry stream size"); 00063 return; 00064 } 00065 00066 // Load the data item into the telemetry stream and check that the 00067 // telemetry stream object becomes configured 00068 pTmStream->setDataItem(0,pd1); 00069 pTmStream->setDataItem(1,pd2); 00070 pTmStream->setDataItem(2,pd3); 00071 if ( !pTmStream->isObjectConfigured() ) 00072 { setTestResult(TEST_FAILURE, "Wrong object configuration status"); 00073 return; 00074 } 00075 00076 // Check that the telemetry packet can be written to the telemetry stream 00077 if ( !pTmStream->doesPacketFit(pTW1) ) 00078 { setTestResult(TEST_FAILURE, "Check on telemetry stream capacity failed"); 00079 return; 00080 } 00081 00082 // Make a write request to the telemetry stream and check correctness 00083 // (Recall that when a pair of bytes read from the telemetry packet are 00084 // written to a data item, the first byte is overlaid upon the least 00085 // significant byte of the data item and the second byte is overlaid upon 00086 // the most significant byte) 00087 pTmStream->write(pTW1); 00088 if ( (pd1->getUnsignedShort() != d1+256*d2) || 00089 (pd2->getUnsignedShort() != d3+256*d4) ) 00090 { setTestResult(TEST_FAILURE, "Write operations failed"); 00091 return; 00092 } 00093 00094 // Check whether the telemetry packet can be written again to the telemetry stream 00095 if ( pTmStream->doesPacketFit(pTW1) ) 00096 { setTestResult(TEST_FAILURE, "Check on telemetry stream capacity failed"); 00097 return; 00098 } 00099 00100 // Rewrite the telemetry packet and check that the first two bytes were correctly written 00101 pTmStream->write(pTW1); 00102 if ( (pd3->getUnsignedShort() != d1+256*d2) ) 00103 { setTestResult(TEST_FAILURE, "Write operations failed"); 00104 return; 00105 } 00106 00107 // Reset the telemetry stream and clear all data items 00108 pTmStream->reset(); 00109 pd1->setUnsignedShort(0); 00110 pd2->setUnsignedShort(0); 00111 pd3->setUnsignedShort(0); 00112 00113 // Check that the telemetry packet can be written to the telemetry stream 00114 if ( !pTmStream->doesPacketFit(pTW1) ) 00115 { setTestResult(TEST_FAILURE, "Check on telemetry stream capacity failed"); 00116 return; 00117 } 00118 00119 // Make a write request to the telemetry stream and check correctness 00120 pTmStream->write(pTW1); 00121 if ( (pd1->getUnsignedShort() != d1+256*d2) || 00122 (pd2->getUnsignedShort() != d3+256*d4) ) 00123 { setTestResult(TEST_FAILURE, "Write operations failed"); 00124 return; 00125 } 00126 00127 setTestResult(TEST_SUCCESS,"Test Successful"); 00128 return; 00129 00130 }
Copyright 2003 P&P Software GmbH - All Rights Reserved