MCPcopy Create free account
hub / github.com/SmingHub/Sming / execute

Method execute

tests/HostTests/modules/TemplateStream.cpp:32–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30 }
31
32 void execute() override
33 {
34 TEST_CASE("template1.1")
35 {
36 FSTR::TemplateStream tmpl(template1);
37 tmpl.onGetValue([](const char* name) -> String {
38 if(FS("var1") == name) {
39 return F("value #1");
40 }
41 if(FS("var2") == name) {
42 return F("value #2");
43 }
44 return nullptr;
45 });
46
47 check(tmpl, template1, template1_1);
48 }
49
50 TEST_CASE("template1.2")
51 {
52 FSTR::TemplateStream tmpl(template1);
53 tmpl.setVar("var3", "[value #3]");
54 tmpl.onGetValue([](const char* name) -> String {
55 if(FS("var1") == name) {
56 return F("value #1");
57 }
58 if(FS("var2") == name) {
59 return F("value #2");
60 }
61 return nullptr;
62 });
63
64 check(tmpl, template1, template1_2);
65 }
66
67 TEST_CASE("template2.1")
68 {
69 Serial.println(template2);
70 FSTR::TemplateStream tmpl(template2);
71 tmpl.onGetValue([&tmpl](const char* name) -> String {
72 if(FS("disable") == name) {
73 tmpl.enableOutput(false);
74 return "";
75 }
76 if(FS("enable") == name) {
77 tmpl.enableOutput(true);
78 return "";
79 }
80 return nullptr;
81 });
82
83 check(tmpl, template2, template2_1);
84 }
85
86 TEST_CASE("template3 (PR #2400 - HTML)")
87 {
88 FSTR::TemplateStream tmpl(template3);
89 tmpl.setVar("title", "Document Title");

Callers

nothing calls this directly

Calls 15

m_nputsFunction · 0.85
m_putsFunction · 0.85
setVarMethod · 0.80
printlnMethod · 0.80
enableOutputMethod · 0.80
sectionCountMethod · 0.80
setDoubleBracesMethod · 0.80
setLengthMethod · 0.80
FFunction · 0.50
onGetValueMethod · 0.45
copyFromMethod · 0.45
gotoSectionMethod · 0.45

Tested by

no test coverage detected