Skip to content

Commit

Permalink
Fix size_t warning windows
Browse files Browse the repository at this point in the history
Signed-off-by: Emerson Knapp <[email protected]>
  • Loading branch information
emersonknapp committed Sep 13, 2021
1 parent ccbf1f9 commit a600d06
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions rosbag2_cpp/test/rosbag2_cpp/test_circular_message_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ using namespace testing; // NOLINT

namespace
{
inline size_t abs_diff(size_t a, size_t b) {
return a < b ? b - a : a - b;
}

std::shared_ptr<rosbag2_storage::SerializedBagMessage> make_test_msg()
{
static uint32_t counter = 0;
Expand Down Expand Up @@ -61,7 +65,7 @@ class CircularMessageCacheTest : public Test

virtual ~CircularMessageCacheTest() = default;

const size_t cache_size_ {1 * 500}; // ~0.5 Kb cache
const size_t cache_size_ {1 * 500}; // 500B cache
};

TEST_F(CircularMessageCacheTest, circular_message_cache_overwrites_old) {
Expand Down Expand Up @@ -90,10 +94,11 @@ TEST_F(CircularMessageCacheTest, circular_message_cache_overwrites_old) {
message_data_size += msg->serialized_data->buffer_length;
}

int cache_size_diff = cache_size_ - message_data_size;
size_t cache_size_diff = cache_size_ - message_data_size;
size_t allowed_diff{10};

// Actual stored data size should be roughly the desired cache size
EXPECT_THAT(std::abs(cache_size_diff), Lt(10));
EXPECT_THAT(cache_size_diff, Lt(allowed_diff));
}

TEST_F(CircularMessageCacheTest, circular_message_cache_ensure_empty) {
Expand Down

0 comments on commit a600d06

Please sign in to comment.