Skip to content

Commit 6811eed

Browse files
committed
test(sensors): align Dallas node tests with the stricter 85 Β°C rule
The real-node suite still expected three 85 Β°C reads to confirm the value. It now expects the reading to stay invalid without a rescan and a recovered value to be accepted. A new test re-maps the role to another probe that reports 85 Β°C and checks that the previous probe's value is not held (fails without the filter reset in applyPendingAddressFilter). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012JY8RZscs5W8tLQMuZB95K
1 parent 97c09d5 commit 6811eed

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

β€Žtest/native/dallas_node/test_dallas_node.cppβ€Ž

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,32 @@ void test_unconfirmed_power_on_value_is_not_a_failure() {
110110
CHECK(std::isnan(solar.getTemperature()));
111111
CHECK(bus.beginCalls() == beginsAfterSetup);
112112

113-
measure(solar); // third consecutive 85 Β°C confirms the value
114-
CHECK(solar.getTemperature() == 85.0f);
113+
measure(solar); // repetition never confirms the power-on value
114+
CHECK(std::isnan(solar.getTemperature()));
115115
CHECK(bus.beginCalls() == beginsAfterSetup);
116+
117+
bus.setReading(kSolarProbe, 42.0f);
118+
measure(solar); // supply recovered
119+
CHECK(solar.getTemperature() == 42.0f);
120+
}
121+
122+
void test_mapping_change_resets_filter_history() {
123+
section("a mapping change to another probe does not hold the previous probe's value");
124+
PoolController::SensorSlots::reset();
125+
DallasTemperature bus;
126+
bus.addDevice(kSolarProbe, 40.0f);
127+
bus.addDevice(kPoolProbe, 24.0f);
128+
DallasTemperatureNode solar(SensorId::SOLAR, "solar-temp", "Solar", &bus, 0);
129+
solar.begin();
130+
measure(solar);
131+
CHECK(solar.getTemperature() == 40.0f);
132+
133+
// Re-map the role to the other probe, which reports its power-on value.
134+
bus.setReading(kPoolProbe, 85.0f);
135+
solar.setAddressFilter(kPoolProbe);
136+
measure(solar);
137+
CHECK(std::isnan(solar.getTemperature())); // not HOLD of the old probe's 40 Β°C
138+
CHECK(!solar.isSensorFound());
116139
}
117140

118141
} // namespace
@@ -121,6 +144,7 @@ int main() {
121144
test_shared_bus_never_hands_pool_probe_to_solar();
122145
test_three_failed_reads_trigger_one_rescan();
123146
test_unconfirmed_power_on_value_is_not_a_failure();
147+
test_mapping_change_resets_filter_history();
124148

125149
printf("\n══════════════════════════════════════════════════\n");
126150
printf(" Dallas Node Results: %d passed, %d failed\n", g_passed, g_failed);

0 commit comments

Comments
Β (0)