| 32 | } |
| 33 | |
| 34 | void Test(vector<TrafficGPSEncoder::DataPoint> & points) |
| 35 | { |
| 36 | double constexpr kEps = 1e-5; |
| 37 | |
| 38 | for (uint32_t version = 0; version <= TrafficGPSEncoder::kLatestVersion; ++version) |
| 39 | { |
| 40 | vector<uint8_t> buf; |
| 41 | MemWriter<decltype(buf)> memWriter(buf); |
| 42 | UNUSED_VALUE(TrafficGPSEncoder::SerializeDataPoints(version, memWriter, points)); |
| 43 | |
| 44 | vector<TrafficGPSEncoder::DataPoint> result; |
| 45 | MemReader memReader(buf.data(), buf.size()); |
| 46 | ReaderSource<MemReader> src(memReader); |
| 47 | TrafficGPSEncoder::DeserializeDataPoints(version, src, result); |
| 48 | |
| 49 | TEST_EQUAL(points.size(), result.size(), ()); |
| 50 | for (size_t i = 0; i < points.size(); ++i) |
| 51 | { |
| 52 | TEST_EQUAL(points[i].m_timestamp, result[i].m_timestamp, (points[i].m_timestamp, result[i].m_timestamp)); |
| 53 | TEST(AlmostEqualAbsOrRel(points[i].m_latLon.m_lat, result[i].m_latLon.m_lat, kEps), |
| 54 | (points[i].m_latLon.m_lat, result[i].m_latLon.m_lat)); |
| 55 | TEST(AlmostEqualAbsOrRel(points[i].m_latLon.m_lon, result[i].m_latLon.m_lon, kEps), |
| 56 | (points[i].m_latLon.m_lon, result[i].m_latLon.m_lon)); |
| 57 | } |
| 58 | |
| 59 | if (version == TrafficGPSEncoder::kLatestVersion) |
| 60 | { |
| 61 | LOG(LINFO, |
| 62 | ("path length =", CalculateLength(points), "num points =", points.size(), "compressed size =", buf.size())); |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | UNIT_TEST(Traffic_Serialization_Smoke) |
| 68 | { |
no test coverage detected