address bot comments

This commit is contained in:
J. Nick Koston
2026-02-28 14:04:28 -10:00
parent 2224132e03
commit 8e7b1638d0
2 changed files with 20 additions and 0 deletions
+15
View File
@@ -68,3 +68,18 @@ def test_text_config_lamda_is_set(generate_main):
# Then
assert "it_4->set_template([]() -> std::optional<std::string> {" in main_cpp
assert 'return std::string{"Hello"};' in main_cpp
def test_esphome_optional_alias_works(generate_main):
"""
Test that esphome::optional alias compiles (backward compatibility)
"""
# Given
# When
main_cpp = generate_main("tests/component_tests/text/test_text.yaml")
# Then
# Codegen emits std::optional, but esphome::optional must also work
# via the using alias in esphome/core/optional.h
assert "std::optional<std::string>" in main_cpp
@@ -31,6 +31,11 @@ esphome:
id(template_sens).set_template([]() -> std::optional<float> {
return 123.0f;
});
# Test that esphome::optional alias still works for backward compatibility
- lambda: |-
id(template_sens).set_template([]() -> esphome::optional<float> {
return 42.0f;
});
- datetime.date.set:
id: test_date