MCPcopy Create free account
hub / github.com/comaps/comaps / DecodeDataPacketVersionTest

Function DecodeDataPacketVersionTest

libs/tracking/tracking_tests/protocol_test.cpp:91–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89
90template <typename Container>
91void DecodeDataPacketVersionTest(Container const & points, Protocol::PacketType version)
92{
93 double const kEps = 1e-5;
94
95 auto packet = Protocol::CreateDataPacket(points, version);
96 TEST_GREATER(packet.size(), 0, ());
97 TEST_EQUAL(Protocol::PacketType(packet[0]), version, ());
98
99 auto payload = vector<uint8_t>(begin(packet) + sizeof(uint32_t /* header */), end(packet));
100 Container result = Protocol::DecodeDataPacket(version, payload);
101
102 TEST_EQUAL(points.size(), result.size(), ());
103 for (size_t i = 0; i < points.size(); ++i)
104 {
105 TEST_EQUAL(points[i].m_timestamp, result[i].m_timestamp, (points[i].m_timestamp, result[i].m_timestamp));
106 TEST(AlmostEqualAbsOrRel(points[i].m_latLon.m_lat, result[i].m_latLon.m_lat, kEps),
107 (points[i].m_latLon.m_lat, result[i].m_latLon.m_lat));
108 TEST(AlmostEqualAbsOrRel(points[i].m_latLon.m_lon, result[i].m_latLon.m_lon, kEps),
109 (points[i].m_latLon.m_lon, result[i].m_latLon.m_lon));
110 }
111}
112
113UNIT_TEST(Protocol_DecodeDataPacket)
114{

Callers 1

UNIT_TESTFunction · 0.85

Calls 6

PacketTypeEnum · 0.85
TESTFunction · 0.85
AlmostEqualAbsOrRelFunction · 0.85
beginFunction · 0.50
endFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected