Skip to content

Commit

Permalink
#272: Adjust unit tests to work properly with SERIALIZATION_ERROR_CHE…
Browse files Browse the repository at this point in the history
…CKING flag
  • Loading branch information
thearusable committed Jun 10, 2024
1 parent 575b9a6 commit fd8449e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/unit/test_tuple.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,12 @@ static void testTupleSerialization(std::tuple<T, int> before) {
auto first_part_size = checkpoint::serialize(first_part)->getSize();

// calculate serialized buffer size for std::tuple<int>
#if defined(SERIALIZATION_ERROR_CHECKING)
auto second_part = std::make_tuple(std::get<1>(before));
auto second_part_size = checkpoint::serialize(second_part)->getSize();
#else
auto second_part_size = sizeof(std::tuple<int>);
#endif

// Calculate serialized buffer size for std::tuple<T, int>
auto ret = checkpoint::serialize(before);
Expand Down Expand Up @@ -164,13 +168,18 @@ TEST_F(TestTuple, test_tuple_empty_base_optimization) {
EXPECT_NE(sizeof(Base) + sizeof(int), sizeof(Derived));

// Check serialization buffer sizes for the types without tuple
auto base = Base();
auto base_size = checkpoint::serialize(base)->getSize();
auto some_int = 4;
auto some_int_size = checkpoint::serialize(some_int)->getSize();
auto derived = Derived(12345);
auto derived_size = checkpoint::serialize(derived)->getSize();

#if defined(SERIALIZATION_ERROR_CHECKING)
auto base = Base();
auto base_size = checkpoint::serialize(base)->getSize();
EXPECT_EQ(base_size + some_int_size, derived_size);
#else
EXPECT_EQ(some_int_size, derived_size);
#endif

testTupleSerialization<Base>(std::make_tuple(Base(), 0));
testTupleSerialization<DerivedEmpty>(std::make_tuple(DerivedEmpty(), 0));
Expand Down

0 comments on commit fd8449e

Please sign in to comment.