MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / TEST

Function TEST

pj_scripting/tests/lua_time_precision_test.cpp:41–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39} // namespace
40
41TEST(LuaTimePrecision, RebasedDerivativeIsExactAtNanosecondScale) {
42 auto engine = makeLuauEngine();
43 auto classes = engine->inspectModule(kDerivative, "test");
44 ASSERT_TRUE(classes.has_value());
45 LuaSisoTransform xf(engine, classes->front(), "{}");
46
47 // Two samples 100 ns apart, sitting at a ~2026 absolute epoch.
48 (void)xf.calculateNextPoint(Sample::scalar(kEpochNs, PJ::VarValue{0.0}));
49 auto out = xf.calculateNextPoint(Sample::scalar(kEpochNs + 100, PJ::VarValue{1.0}));
50 ASSERT_TRUE(out.has_value());
51 // dt = 100 ns = 1e-7 s, so d = 1 / 1e-7 = 1e7, exactly (rebasing keeps it).
52 EXPECT_NEAR(PJ::proc::detail::toDouble(out->value()), 1e7, 1.0);
53}
54
55TEST(LuaTimePrecision, NaiveAbsoluteEpochInDoubleCollapses100nsDt) {
56 // The bug the rebasing avoids: subtracting two absolute-epoch doubles.

Callers

nothing calls this directly

Calls 5

makeLuauEngineFunction · 0.85
toDoubleFunction · 0.50
inspectModuleMethod · 0.45
calculateNextPointMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected