[light] Cover get_effects() as published configs use it in the component test (#20203)

This commit is contained in:
J. Nick Koston
2026-10-05 21:07:37 -05:00
committed by GitHub
parent 082a0b746a
commit 6191b7553e
+15
View File
@@ -28,6 +28,21 @@ esphome:
ESP_LOGI("test", "Name length: %d", (int) name.size());
}
# get_effects() shapes used by published configs and external components
- lambda: |-
const auto &effects = id(test_monochromatic_light).get_effects();
auto &same = id(test_monochromatic_light).get_effects();
uint32_t total = effects.size();
for (auto *effect : effects) {
ESP_LOGD("test", "Effect %s", effect->get_name().c_str());
}
if (total > 0) {
ESP_LOGD("test", "First %s", effects.at(0)->get_name().c_str());
// Raw pointer iterators on purpose: external code binds std::find's result to `const auto *`
auto *it = std::find(same.begin(), same.end(), effects[0]);
ESP_LOGD("test", "Index %d", (int) (it - same.begin()));
}
# Test LightState::get_effect_name() returns StringRef
- lambda: |-
// Test LightState::get_effect_name() returns StringRef