Skip to content

Commit

Permalink
Fix warnings and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-attack committed Feb 15, 2025
1 parent 6009673 commit 016014b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/pubsub_cpp/array_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ArrayVector

length_ = arr.size();
data_ = (T*)malloc(sizeof(T)*length_);
for (int i = 0; i < length_; i++)
for (uint32_t i = 0; i < length_; i++)
{
data_[i] = arr[i];
}
Expand All @@ -82,7 +82,7 @@ class ArrayVector

auto new_data = (T*)malloc(sizeof(T)*size);
auto copy_len = std::min(size, length_);
for (int i = 0; i < copy_len; i++)
for (uint32_t i = 0; i < copy_len; i++)
{
new_data[i] = data_[i];
}
Expand Down
7 changes: 5 additions & 2 deletions tests/test_pubsub_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ TEST(test_publish_subscribe_generic, []() {

static bool got_message = false;
//options.preferred_transport = tcp ? 1 : 0;
options.cb = [](void* message, unsigned int size, void* data2, const ps_msg_info_t* info)
options.cb_raw = [](void* message, unsigned int size, void* data2, const ps_msg_info_t* info)
{
got_message = true;
// todo need to also assert we have the message type
Expand All @@ -60,6 +60,8 @@ TEST(test_publish_subscribe_generic, []() {
EXPECT(strcmp(data->value, rmsg.value) == 0);
free(data->value);
free(data);

free(message);
};
ps_node_create_subscriber_adv(&node, "/data", 0, &string_sub, &options);

Expand Down Expand Up @@ -169,7 +171,7 @@ TEST(test_publish_subscribe_large, []() {

static bool got_message = false;
options.preferred_transport = 1;
options.cb = [](void* message, unsigned int size, void* data2, const ps_msg_info_t* info)
options.cb_raw = [](void* message, unsigned int size, void* data2, const ps_msg_info_t* info)
{
got_message = true;
printf("Got message\n");
Expand All @@ -180,6 +182,7 @@ TEST(test_publish_subscribe_large, []() {
EXPECT(data->num_points == rmsg.num_points);
free(data->data);
free(data);
free(message);
};
ps_node_create_subscriber_adv(&node, "/data", 0, &string_sub, &options);

Expand Down

0 comments on commit 016014b

Please sign in to comment.