Skip to content

Commit

Permalink
[C++] test message length functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Egor Seredin committed Mar 4, 2020
1 parent e4d86a6 commit 693c052
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions sbe-tool/src/test/cpp/CodeGenTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,25 @@ TEST_F(CodeGenTest, shouldBeAbleToEncodeCarCorrectly)
offset += COLOR_LENGTH;

EXPECT_EQ(sz, offset);

std::uint64_t predictedCarSz = Car::messageLength(
{
FUEL_FIGURES_1_USAGE_DESCRIPTION_LENGTH,
FUEL_FIGURES_2_USAGE_DESCRIPTION_LENGTH,
FUEL_FIGURES_3_USAGE_DESCRIPTION_LENGTH
},
{
ACCELERATION_COUNT,
ACCELERATION_COUNT
},
MANUFACTURER_LENGTH,
MODEL_LENGTH,
ACTIVATION_CODE_LENGTH,
COLOR_LENGTH
);
EXPECT_EQ(sz, predictedCarSz);
EXPECT_EQ(Car::isConstLength(), false);
EXPECT_EQ(Car::PerformanceFigures::Acceleration::isConstLength(), true);
}

TEST_F(CodeGenTest, shouldBeAbleToEncodeHeaderPlusCarCorrectly)
Expand Down
2 changes: 2 additions & 0 deletions sbe-tool/src/test/cpp/CompositeElementsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ TEST_F(CompositeElementsTest, shouldEncodeMsgCorrectly)
std::uint64_t offset = 0;

ASSERT_EQ(sz, 8u + 22u);
ASSERT_EQ(Msg::isConstLength(), true);
EXPECT_EQ(sz, Msg::sbeBlockAndHeaderLength());

EXPECT_EQ(*((std::uint16_t *)(bufferPtr + offset)), Msg::sbeBlockLength());
offset += sizeof(std::uint16_t);
Expand Down

0 comments on commit 693c052

Please sign in to comment.