18static void make(uint8_t* out, uint64_t ts, uint8_t type, uint16_t sensor,
float ref) {
20 std::memcpy(out, &ts, 8);
22 std::memcpy(out + 10, &sensor, 2);
23 std::memcpy(out + 12, &ref, 4);
30 make(
a, 1000, 5, 4206, 75.f);
31 CHECK(!d.
seen(
a),
"a first command is handled");
32 CHECK(d.
seen(
a),
"the same command arriving again (a second subscription) is dropped");
36 for (
int i = 0; i < 10; ++i) {
37 make(
b, 2000 + 120 * i, 5, 4202, 100.f);
38 for (
int copy = 0; copy < 2; ++copy)
42 CHECK(handled == 10,
"ten captures delivered twice are handled ten times");
45 make(
a, 5000, 5, 4206, 75.f);
46 make(
b, 5001, 5, 4206, 75.f);
47 CHECK(!d.
seen(
a) && !d.
seen(
b),
"two captures a millisecond apart are both handled");
51 make(c, 6000, 5, 4206, 75.f);
53 make(c, 6000, 6, 4206, 75.f);
55 make(c, 6000, 5, 4207, 75.f);
57 make(c, 6000, 5, 4206, 76.f);
62 make(
a, 1, 5, 1, 0.f);
65 make(
b, 100 + i, 5, 1, 0.f);
68 CHECK(!e.
seen(
a),
"only the last kDepth commands are remembered");
71 std::printf(
"command_dedupe: all checks passed\n");