| 89 | |
| 90 | template <typename Container> |
| 91 | void 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 | |
| 113 | UNIT_TEST(Protocol_DecodeDataPacket) |
| 114 | { |
no test coverage detected