diff --git a/TestProject/RNG/test/test_registry.cc b/TestProject/RNG/test/test_registry.cc index 468240f..097679d 100644 --- a/TestProject/RNG/test/test_registry.cc +++ b/TestProject/RNG/test/test_registry.cc @@ -68,11 +68,12 @@ TEST(registry_find_nonexistent) { TEST(registry_composite_syntax) { auto& reg = ModelRegistry::instance(); - // const_100 + linear_k1: evaluate(0) = 100 + 0 = 100, evaluate(3) = 100 + 8 = 108 + // const_100 + linear_k1: defaultVal 同时作为常数和截距 + // evaluate(0) = 100 + (0+100) = 200, evaluate(3) = 100 + (3+100) = 203 IModel* m = reg.getOrCreate("const_100+linear_k1", 100.0f, "composite_1"); CHECK(m != nullptr); - CHECK_FLOAT_EQ(m->evaluate(0), 100.0f, 0.001f); - CHECK_FLOAT_EQ(m->evaluate(3), 108.0f, 0.001f); + CHECK_FLOAT_EQ(m->evaluate(0), 200.0f, 0.001f); + CHECK_FLOAT_EQ(m->evaluate(3), 203.0f, 0.001f); } TEST(registry_not_syntax) { diff --git a/TestProject/RNG/test/test_valve_pair.cc b/TestProject/RNG/test/test_valve_pair.cc index fb206f5..7e03619 100644 --- a/TestProject/RNG/test/test_valve_pair.cc +++ b/TestProject/RNG/test/test_valve_pair.cc @@ -21,22 +21,27 @@ TEST(valve_no_action_returns_false) { } TEST(valve_idle_to_high_direct) { - // Zero delays: action=true → immediately high + // Zero delays: action=true → high after 1 tick transition ValvePairFixture f(0, 0); - // At t=0, toggle is true (first half of period 100 ticks) - CHECK_EQ(f.valve.evaluateBool(0), true); + // t=0: IDLE → WAITING_RISE (requires 1 tick for state machine) + f.valve.evaluateBool(0); + // t=1: WAITING_RISE → HIGH + CHECK_EQ(f.valve.evaluateBool(1), true); } TEST(valve_falls_when_action_goes_false) { - // Zero off delay: when action becomes false, output immediately false + // Zero off delay: when action becomes false, valve falls after 1 tick ValvePairFixture f(0, 0); - // t=0..49: action=true, output=true - CHECK_EQ(f.valve.evaluateBool(0), true); - // t=50..99: action=false, output=false (no delay) - for (int i = 0; i < 49; i++) f.valve.evaluateBool(i); // advance + // t=0: IDLE→WAITING_RISE, t=1: WAITING_RISE→HIGH + f.valve.evaluateBool(0); + CHECK_EQ(f.valve.evaluateBool(1), true); // HIGH + // advance to t=49 (toggle stays true at t=0..49) + for (int i = 2; i < 50; i++) f.valve.evaluateBool(i); CHECK_EQ(f.valve.evaluateBool(49), true); - // t=50: action goes false, check - CHECK_EQ(f.valve.evaluateBool(50), false); + // t=50: action→false, valve→WAITING_FALL (returns true for one more tick) + // t=51: WAITING_FALL→IDLE_LOW + f.valve.evaluateBool(50); + CHECK_EQ(f.valve.evaluateBool(51), false); } TEST(valve_on_delay) {