mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 03:16:37 +00:00
Add test for set_effect with const char* literal
Ensures the const char* overload resolves the ambiguous call reported in #14728.
This commit is contained in:
@@ -33,7 +33,7 @@ class AddressableLightDisplay : public display::DisplayBuffer {
|
|||||||
// - Save the current effect index.
|
// - Save the current effect index.
|
||||||
this->last_effect_index_ = light_state_->get_current_effect_index();
|
this->last_effect_index_ = light_state_->get_current_effect_index();
|
||||||
// - Disable any current effect.
|
// - Disable any current effect.
|
||||||
light_state_->make_call().set_effect(0).perform();
|
light_state_->make_call().set_effect(uint32_t{0}).perform();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enabled_ = enabled;
|
enabled_ = enabled;
|
||||||
|
|||||||
@@ -506,7 +506,7 @@ color_mode_bitmask_t LightCall::get_suitable_color_modes_mask_() {
|
|||||||
|
|
||||||
LightCall &LightCall::set_effect(const char *effect, size_t len) {
|
LightCall &LightCall::set_effect(const char *effect, size_t len) {
|
||||||
if (len == 4 && strncasecmp(effect, "none", 4) == 0) {
|
if (len == 4 && strncasecmp(effect, "none", 4) == 0) {
|
||||||
this->set_effect(0);
|
this->set_effect(uint32_t{0});
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,12 @@ esphome:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Test set_effect with const char* doesn't cause ambiguous overload (issue #14728)
|
||||||
|
- lambda: |-
|
||||||
|
auto call = id(test_monochromatic_light).turn_on();
|
||||||
|
call.set_effect("None");
|
||||||
|
call.perform();
|
||||||
|
|
||||||
- light.toggle: test_binary_light
|
- light.toggle: test_binary_light
|
||||||
- light.turn_off: test_rgb_light
|
- light.turn_off: test_rgb_light
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
|
|||||||
Reference in New Issue
Block a user