Skip to content

Commit

Permalink
Network: add test-case for parser re-synchronization
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasDebrunner committed Dec 15, 2023
1 parent f674f3f commit e34db1c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,19 @@ TEST_CASE("Create network runtime") {
CHECK_EQ(message.name(), "TEST_MESSAGE");
}

SUBCASE("Receiver re-synchronizes when garbage data between messages") {
interface.reset();
auto expectation_1 = connection->expect("TEST_MESSAGE");
auto expectation_2 = connection->expect("TEST_MESSAGE");
interface.addToReceiveQueue("\xfd\x10\x00\x00\x01\x61\x61\xbc\x26\x00\x2a\x00\x00\x00\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x21\x53\xd9"s, interface_partner);
interface.addToReceiveQueue("this is garbage data"s, interface_partner);
interface.addToReceiveQueue("\xfd\x10\x00\x00\x01\x61\x61\xbc\x26\x00\x2a\x00\x00\x00\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x21\x53\xd9"s, interface_partner);
auto message_1 = connection->receive(expectation_1);
CHECK_EQ(message_1.name(), "TEST_MESSAGE");
auto message_2 = connection->receive(expectation_2);
CHECK_EQ(message_2.name(), "TEST_MESSAGE");
}

SUBCASE("Can not receive message from wrong partner") {
interface.reset();
auto expectation = connection->expect("TEST_MESSAGE");
Expand Down

0 comments on commit e34db1c

Please sign in to comment.