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

TestCaseByteArrayTelemetryStream_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseByteArrayTelemetryStream_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/TestCompilerSwitches.h" 00012 #include "../GeneralInclude/ClassId.h" 00013 #include "../GeneralInclude/TestConstants.h" 00014 #include "../Telemetry/DC_ByteArrayTelemetryStream.h" 00015 #include "../Telemetry/DC_DummyTelemetryPacket.h" 00016 #include "TestCaseByteArrayTelemetryStream_1.h" 00017 00018 TestCaseByteArrayTelemetryStream_1::TestCaseByteArrayTelemetryStream_1(void) : 00019 TestCaseGenericSetUp(ID_BYTEARRAYTELEMETRYSTREAM*10+1,"TestCaseByteArrayTelemetryStream_1") { 00020 return; 00021 } 00022 00023 void TestCaseByteArrayTelemetryStream_1::runTestCase(void) { 00024 00025 // Create the byte array 00026 unsigned int const size = 5; 00027 unsigned char ba[size]; 00028 for (int i=0; i<size; i++) 00029 ba[i]=0; 00030 00031 // Create the telemetry stream component 00032 DC_ByteArrayTelemetryStream* pTmStream = new DC_ByteArrayTelemetryStream(); 00033 00034 // Create and configure the telemetry packet to be written to the stream 00035 DC_DummyTelemetryPacket* pTI = new DC_DummyTelemetryPacket(); 00036 pTI->setNumberOfBytes(2); 00037 pTI->setValue(0,1); 00038 pTI->setValue(1,2); 00039 00040 // Check the value of the class identifier 00041 if ( pTmStream->getClassId() != ID_BYTEARRAYTELEMETRYSTREAM ) 00042 { setTestResult(TEST_FAILURE, "Wrong class identifier"); 00043 return; 00044 } 00045 00046 // Check that the telemetry stream is not configured 00047 if ( pTmStream->isObjectConfigured() ) 00048 { setTestResult(TEST_FAILURE, "Wrong object configuration status"); 00049 return; 00050 } 00051 00052 // Set the size of the byte array and verify correctness 00053 pTmStream->setCapacity(size); 00054 if ( pTmStream->getCapacity() != size ) 00055 { setTestResult(TEST_FAILURE, "Wrong telemetry stream size"); 00056 return; 00057 } 00058 00059 // Set the starting address of the byte array and verify correctness 00060 pTmStream->setStartingAddress(ba); 00061 if ( pTmStream->getStartingAddress() != ba ) 00062 { setTestResult(TEST_FAILURE, "Wrong byte array starting address"); 00063 return; 00064 } 00065 00066 // Check that the telemetry stream is now configured 00067 if ( !pTmStream->isObjectConfigured() ) 00068 { setTestResult(TEST_FAILURE, "Wrong object configuration status"); 00069 return; 00070 } 00071 00072 // Make write requests and check success 00073 pTmStream->write(pTI); 00074 if ( (ba[0] != 1) || (ba[1] != 2) ) 00075 { setTestResult(TEST_FAILURE, "Write request failed"); 00076 return; 00077 } 00078 00079 // Check doesPacketFit method 00080 if ( !pTmStream->doesPacketFit(pTI) ) 00081 { setTestResult(TEST_FAILURE, "Failure of method doesPacketFit"); 00082 return; 00083 } 00084 00085 // Write a new telemetry packet and check again doesPacketFit method (now it should fail) 00086 pTmStream->write(pTI); 00087 if ( pTmStream->doesPacketFit(pTI) ) 00088 { setTestResult(TEST_FAILURE, "Failure of method doesPacketFit"); 00089 return; 00090 } 00091 00092 // Make a write request that should be only partially executed 00093 pTmStream->write(pTI); 00094 if ( ba[4] != 1 ) 00095 { setTestResult(TEST_FAILURE, "Write request failed"); 00096 return; 00097 } 00098 00099 // Reset telemetry stream and verify new write request 00100 pTmStream->reset(); 00101 pTI->setValue(0,3); 00102 pTI->setValue(1,4); 00103 pTmStream->write(pTI); 00104 if ( (ba[0] != 3) || (ba[1] != 4) ) 00105 { setTestResult(TEST_FAILURE, "Write request failed"); 00106 return; 00107 } 00108 00109 // Saturate again the telemetry stream, flush and write again 00110 pTmStream->write(pTI); 00111 pTmStream->write(pTI); 00112 pTmStream->flush(); 00113 pTI->setValue(0,5); 00114 pTI->setValue(1,6); 00115 pTmStream->write(pTI); 00116 if ( (ba[0] != 5) || (ba[1] != 6) ) 00117 { setTestResult(TEST_FAILURE, "Write request failed"); 00118 return; 00119 } 00120 00121 setTestResult(TEST_SUCCESS,"Test Successful"); 00122 return; 00123 00124 }
Copyright 2003 P&P Software GmbH - All Rights Reserved