Skip to content

Commit

Permalink
Added deserialize test
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Pecka <[email protected]>
  • Loading branch information
peci1 committed Jul 23, 2021
1 parent 5660d34 commit 6be35fb
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/integration/components.cc
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ TEST_F(ComponentsTest, JointPositionLimitsCmd)
// Create components
auto comp1 = components::JointPositionLimitsCmd();
auto comp2 = components::JointPositionLimitsCmd();
components::JointPositionLimitsCmd comp3;

// Equality operators
EXPECT_EQ(comp1, comp2);
Expand All @@ -649,21 +650,33 @@ TEST_F(ComponentsTest, JointPositionLimitsCmd)
comp1.Serialize(ostr);
EXPECT_EQ("0", ostr.str());

auto istr = std::istringstream(ostr.str());
comp3.Deserialize(istr);
EXPECT_EQ(comp1, comp3);

comp2.Data().push_back(math::Vector2d(-1.0, 1.0));

std::ostringstream ostr2;
comp2.Serialize(ostr2);
EXPECT_EQ("1 -1 1", ostr2.str());

istr = std::istringstream(ostr2.str());
comp3.Deserialize(istr);
EXPECT_EQ(comp2, comp3);

comp2.Data().push_back(math::Vector2d(-2.5, 2.5));

std::ostringstream ostr3;
comp2.Serialize(ostr3);
EXPECT_EQ("2 -1 1 -2.5 2.5", ostr3.str());

std::istringstream istr("ignored");
components::JointPositionLimitsCmd comp3;
istr = std::istringstream(ostr3.str());
comp3.Deserialize(istr);
EXPECT_EQ(comp2, comp3);

istr = std::istringstream("ignored");
comp3.Deserialize(istr);
EXPECT_EQ(comp1, comp3);
}

/////////////////////////////////////////////////
Expand Down

0 comments on commit 6be35fb

Please sign in to comment.