Inheritance diagram for Protocols::Generics::Testing::PacketTest:


Using PacketStub, a very light wieght concrete PacketBase, we test the abstract class PacketBase.
Blackbox tests:
Whitebox tests:
The derived classes are recommended to implement scenarios similar to:
void scenarioReadPacket() { refParsePacket(); refReadHeaderFields(); refReadPayloadFields(); } void scenarioWritePacket() { refSetHeaderFields(); refSetPayloadFields(); refWritePacket(); }
scenarioReadPacket() would parse the packet and would then verify that all fields have been read correctly, whereas scenarioWritePacket() would set all the fields and then verify they are written correctly.
All derived classes are advised to write a single test to verify that a default constructed object is correctly initialized (i.e. all fields get the correct default values). Changing the default values would brake the test and that could be a sign that client code has also been broken.
Definition at line 86 of file PacketBaseTest.cpp.
Public Member Functions | |
| void | testReadPacket () |
| Test that header and payload fields are correctly parsed. | |
| void | testWritePacket () |
| Verify that header, payload and trailer fields are correctly written. | |
| void | testReferenceCountIncreaseCopyPacket () |
| Verify that copying a packet results in impicit sharing of private data. | |
| void | testReferenceCountIncreaseAssignPacket () |
| Assigning a packet to another should result in sharing of private data. | |
| void | testReferenceCountDecreaseAssignPacket () |
| When assigning a packet, the ref count of its old data is decreased. | |
| void | testReferenceCountDecreaseDestroyPacket () |
| Destroying a packet would decrease the ref count of the shared data. | |
| void | testReferenceCountDecreaseModifyPacketCopyPrivateData () |
| Calling non-const functions result in copying the private data. | |
| void | testCtorNoRawDataCached () |
| Verify that the ctor does not cache any raw bytes. | |
| void | testParseRawDataCached () |
| Verify that parse() caches the raw bytes passed to it. | |
| void | testInvalidateHeader () |
| Verifies that invalidateHeader() invalidates the cached raw header. | |
| void | testInvalidatePayload () |
| Verifies that invalidatePayload() invalidates the cached raw payload. | |
| void | testRawHeaderUsingCachedHeader () |
| Verifies that the cached header bytes are returned when available. | |
| void | testRawHeaderRebuildingAndCachingHeader () |
| Verifies that the raw header bytes are correctly cached. | |
| void | testRawPayloadUsingCachedPayload () |
| Verifies that the cached raw payload bytes are returned when available. | |
| void | testRawPayloadRebuildingAndCachingPayload () |
| Verifies that the raw payload bytes are correctly cached. | |
| void | testRebuildPacketNotModifyingReferenceCount () |
Private Member Functions | |
| CPPUNIT_TEST_SUITE (PacketTest) | |
| CPPUNIT_TEST (testReadPacket) | |
| CPPUNIT_TEST (testWritePacket) | |
| CPPUNIT_TEST (testReferenceCountIncreaseCopyPacket) | |
| CPPUNIT_TEST (testReferenceCountIncreaseAssignPacket) | |
| CPPUNIT_TEST (testReferenceCountDecreaseAssignPacket) | |
| CPPUNIT_TEST (testReferenceCountDecreaseDestroyPacket) | |
| CPPUNIT_TEST (testReferenceCountDecreaseModifyPacketCopyPrivateData) | |
| CPPUNIT_TEST (testCtorNoRawDataCached) | |
| CPPUNIT_TEST (testParseRawDataCached) | |
| CPPUNIT_TEST (testInvalidateHeader) | |
| CPPUNIT_TEST (testInvalidatePayload) | |
| CPPUNIT_TEST (testRawHeaderUsingCachedHeader) | |
| CPPUNIT_TEST (testRawHeaderRebuildingAndCachingHeader) | |
| CPPUNIT_TEST (testRawPayloadUsingCachedPayload) | |
| CPPUNIT_TEST (testRawPayloadRebuildingAndCachingPayload) | |
| CPPUNIT_TEST (testRebuildPacketNotModifyingReferenceCount) | |
| CPPUNIT_TEST_SUITE_END () | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Verify that the ctor does not cache any raw bytes.
Definition at line 206 of file PacketBaseTest.cpp. |
|
|
Verifies that invalidateHeader() invalidates the cached raw header.
Definition at line 233 of file PacketBaseTest.cpp. |
|
|
Verifies that invalidatePayload() invalidates the cached raw payload.
Definition at line 242 of file PacketBaseTest.cpp. |
|
|
Verify that parse() caches the raw bytes passed to it.
Definition at line 220 of file PacketBaseTest.cpp. |
|
|
Verifies that the raw header bytes are correctly cached.
Definition at line 263 of file PacketBaseTest.cpp. |
|
|
Verifies that the cached header bytes are returned when available.
Definition at line 251 of file PacketBaseTest.cpp. |
|
|
Verifies that the raw payload bytes are correctly cached.
Definition at line 286 of file PacketBaseTest.cpp. |
|
|
Verifies that the cached raw payload bytes are returned when available.
Definition at line 274 of file PacketBaseTest.cpp. |
|
|
Test that header and payload fields are correctly parsed.
Definition at line 109 of file PacketBaseTest.cpp. |
|
|
Packets sharing private data should only be rebuilt once. If there are multiple copies of a packet sharing the same private data, then the first packet that is forced to rebuild and cache its raw bytes representation would do so without detaching itself from the shared private data. In effect the other copies would be able to reuse the cached bytes!
Definition at line 310 of file PacketBaseTest.cpp. |
|
|
When assigning a packet, the ref count of its old data is decreased.
Definition at line 162 of file PacketBaseTest.cpp. |
|
|
Destroying a packet would decrease the ref count of the shared data.
Definition at line 183 of file PacketBaseTest.cpp. |
|
|
Calling non-const functions result in copying the private data.
Definition at line 194 of file PacketBaseTest.cpp. |
|
|
Assigning a packet to another should result in sharing of private data.
Definition at line 148 of file PacketBaseTest.cpp. |
|
|
Verify that copying a packet results in impicit sharing of private data.
Definition at line 137 of file PacketBaseTest.cpp. |
|
|
Verify that header, payload and trailer fields are correctly written.
Definition at line 129 of file PacketBaseTest.cpp. |