Skip to content

Commit

Permalink
Add a message copy test and add a test timeout
Browse files Browse the repository at this point in the history
Re-enable tests
  • Loading branch information
matt-attack committed Feb 15, 2025
1 parent 016014b commit 50a3cd9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
run: cmake .
- name: cmake build
run: cmake --build .
# - name: Run Tests
# run: cd tests && ctest -VV --timeout 5
- name: Run Tests
run: cd tests && ctest -VV
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ foreach(test_file ${tests})
STRING(REGEX REPLACE ${TEST_REGEX} "\\1" test ${test})
message(STATUS " add test: ${test}")
add_test(NAME ${test_file}_${test} COMMAND ${test_file} ${test})
set_tests_properties(${test_file}_${test} PROPERTIES TIMEOUT 10)
endforeach()
endforeach()
6 changes: 0 additions & 6 deletions tests/test_pubsub_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,11 @@
also add a test to test subscriber/publisher numbers
add a way to add a timeout to tests
add a test for generic message handling
make the pose viewer also be able to view odom in pubviz
(maybe think of a way to view velocities)*/

//lets test queue size too

//so for that test, shove over N messages

TEST(test_publish_subscribe_generic, []() {
struct ps_node_t node;
ps_node_init(&node, "test_node", "", true);
Expand Down
35 changes: 29 additions & 6 deletions tests/test_serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
#include "mini_mock.hpp"

TEST(test_joy_serialization, []() {

// try serializing then deserializing a message to make sure it all matches
pubsub::msg::Joy msg;
pubsub::msg::Joy msg;
msg.buttons = 0x12345678;
for (int i = 0; i < 8; i++)
msg.axes[i] = i;
Expand All @@ -29,7 +28,7 @@ TEST(test_joy_serialization, []() {
void test2()
{
// verify that the C type matches the C++ one memory wise
pubsub::msg::Costmap msg;
pubsub::msg::Costmap msg;
msg.width = 100;
msg.height = 200;
msg.resolution = 1.0;
Expand Down Expand Up @@ -57,7 +56,7 @@ TEST(test_costmap_c_cpp, []() {

TEST(test_costmap_serialization, []() {
// try serializing then deserializing a message to make sure it all matches
pubsub::msg::Costmap msg;
pubsub::msg::Costmap msg;
msg.width = 100;
msg.height = 200;
msg.resolution = 1.0;
Expand Down Expand Up @@ -88,7 +87,7 @@ TEST(test_costmap_serialization, []() {

TEST(test_path2d_serialization, []() {
// try serializing then deserializing a message to make sure it all matches
pubsub::msg::Path2D msg;
pubsub::msg::Path2D msg;
msg.frame = 100;
msg.points.resize(123);
for (int i = 0; i < msg.points.size(); i++)
Expand All @@ -114,9 +113,33 @@ TEST(test_path2d_serialization, []() {
delete out;
});

TEST(test_path2d_copy, []() {
// make sure copying a message works
pubsub::msg::Path2D msg;
msg.frame = 100;
msg.points.resize(123);
for (int i = 0; i < msg.points.size(); i++)
{
msg.points[i].x = i*2;
msg.points[i].y = i*2 + 1;
}

pubsub::msg::Path2D msg2 = msg;

EXPECT(msg2.frame == msg.frame);
EXPECT(msg2.points.size() == msg.points.size());
for (int i = 0; i < msg.points.size(); i++)
{
if (msg2.points[i].x != msg.points[i].x)
EXPECT(false);
if (msg2.points[i].y != msg.points[i].y)
EXPECT(false);
}
});

TEST(test_path2d_foreach, []() {
// try serializing then deserializing a message, making sure the foreach loop over it works as expected
pubsub::msg::Path2D msg;
pubsub::msg::Path2D msg;
msg.frame = 100;
msg.points.resize(3);
for (int i = 0; i < msg.points.size(); i++)
Expand Down

0 comments on commit 50a3cd9

Please sign in to comment.