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

Function Test

libs/coding/coding_tests/traffic_test.cpp:34–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34void 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
67UNIT_TEST(Traffic_Serialization_Smoke)
68{

Callers 1

UNIT_TESTFunction · 0.70

Calls 5

TESTFunction · 0.85
AlmostEqualAbsOrRelFunction · 0.85
CalculateLengthFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected