@@ -20,8 +20,8 @@ suite mustache_tests = [] {
20
20
std::string_view layout = R"( {{first_name}} {{last_name}} {{age}})" ;
21
21
22
22
person p{" Henry" , " Foster" , 34 };
23
- auto result = glz::stencil (layout, p). value_or ( " error " ) ;
24
- expect (result == " Henry Foster 34" ) << result ;
23
+ auto result = glz::stencil (layout, p);
24
+ expect (result == " Henry Foster 34" );
25
25
};
26
26
27
27
" person" _test = [] {
@@ -48,7 +48,7 @@ suite mustache_tests = [] {
48
48
auto result = glz::stencil (layout, p).value_or (" error" );
49
49
expect (result == " Henry Foster" ) << result;
50
50
};
51
-
51
+
52
52
// **Regular Section Tests (#)**
53
53
54
54
" section_true" _test = [] {
@@ -68,8 +68,7 @@ suite mustache_tests = [] {
68
68
};
69
69
70
70
" section_with_inner_placeholders" _test = [] {
71
- std::string_view layout =
72
- R"( {{first_name}} {{last_name}} {{#employed}}Status: Employed, Age: {{age}}{{/employed}})" ;
71
+ std::string_view layout = R"( {{first_name}} {{last_name}} {{#employed}}Status: Employed, Age: {{age}}{{/employed}})" ;
73
72
74
73
person p{" Carol" , " Davis" , 30 , true , true };
75
74
auto result = glz::stencil (layout, p).value_or (" error" );
@@ -93,8 +92,7 @@ suite mustache_tests = [] {
93
92
};
94
93
95
94
" nested_sections" _test = [] {
96
- std::string_view layout =
97
- R"( {{first_name}} {{last_name}} {{#employed}}Status: Employed {{#hungry}}and Hungry{{/hungry}}{{/employed}})" ;
95
+ std::string_view layout = R"( {{first_name}} {{last_name}} {{#employed}}Status: Employed {{#hungry}}and Hungry{{/hungry}}{{/employed}})" ;
98
96
99
97
person p1{" Frank" , " Taylor" , 50 , true , true }; // employed is true, hungry is true
100
98
auto result1 = glz::stencil (layout, p1);
@@ -115,15 +113,14 @@ suite mustache_tests = [] {
115
113
};
116
114
117
115
" section_mismatched_closing_tag" _test = [] {
118
- std::string_view layout =
119
- R"( {{first_name}} {{last_name}} {{#employed}}Employed{{/employment}})" ; // Mismatched closing tag
116
+ std::string_view layout = R"( {{first_name}} {{last_name}} {{#employed}}Employed{{/employment}})" ; // Mismatched closing tag
120
117
121
118
person p{" Ivy" , " Thomas" , 29 , false , true };
122
119
auto result = glz::stencil (layout, p);
123
120
expect (not result.has_value ());
124
121
expect (result.error () == glz::error_code::unexpected_end);
125
122
};
126
-
123
+
127
124
// **Inverted Section Tests**
128
125
129
126
" inverted_section_true" _test = [] {
@@ -143,40 +140,36 @@ suite mustache_tests = [] {
143
140
};
144
141
145
142
" inverted_section_with_extra_text_true" _test = [] {
146
- std::string_view layout =
147
- R"( {{first_name}} {{last_name}} {{^hungry}}I'm not hungry{{/hungry}}. Have a nice day!)" ;
143
+ std::string_view layout = R"( {{first_name}} {{last_name}} {{^hungry}}I'm not hungry{{/hungry}}. Have a nice day!)" ;
148
144
149
145
person p{" Henry" , " Foster" , 34 , false }; // hungry is false
150
146
auto result = glz::stencil (layout, p).value_or (" error" );
151
147
expect (result == " Henry Foster I'm not hungry. Have a nice day!" ) << result;
152
148
};
153
149
154
150
" inverted_section_with_extra_text_false" _test = [] {
155
- std::string_view layout =
156
- R"( {{first_name}} {{last_name}} {{^hungry}}I'm not hungry{{/hungry}}. Have a nice day!)" ;
151
+ std::string_view layout = R"( {{first_name}} {{last_name}} {{^hungry}}I'm not hungry{{/hungry}}. Have a nice day!)" ;
157
152
158
153
person p{" Henry" , " Foster" , 34 , true }; // hungry is true
159
154
auto result = glz::stencil (layout, p).value_or (" error" );
160
155
expect (result == " Henry Foster . Have a nice day!" ) << result;
161
156
};
162
157
163
158
" nested_inverted_section" _test = [] {
164
- std::string_view layout =
165
- R"( {{first_name}} {{last_name}} {{^hungry}}I'm not hungry {{^employed}}and not employed{{/employed}}{{/hungry}})" ;
159
+ std::string_view layout = R"( {{first_name}} {{last_name}} {{^hungry}}I'm not hungry {{^employed}}and not employed{{/employed}}{{/hungry}})" ;
166
160
167
- person p1{" Henry" , " Foster" , 34 , false , false };
168
- auto result1 = glz::stencil (layout, p1).value_or (" error" );
169
- expect (result1 == " Henry Foster I'm not hungry and not employed" ) << result1;
161
+ person p1{" Henry" , " Foster" , 34 , false , false };
162
+ auto result1 = glz::stencil (layout, p1).value_or (" error" );
163
+ expect (result1 == " Henry Foster I'm not hungry and not employed" ) << result1;
170
164
171
- person p2{" Henry" , " Foster" , 34 , false , true };
172
- auto result2 = glz::stencil (layout, p2).value_or (" error" );
173
- expect (result2 == " Henry Foster I'm not hungry " ) << result2;
165
+ person p2{" Henry" , " Foster" , 34 , false , true };
166
+ auto result2 = glz::stencil (layout, p2).value_or (" error" );
167
+ expect (result2 == " Henry Foster I'm not hungry " ) << result2;
174
168
175
- person p3{" Henry" , " Foster" , 34 , true , false };
176
- std::string_view layout_skip =
177
- R"( {{first_name}} {{last_name}} {{^hungry}}I'm not hungry {{^employed}}and not employed{{/employed}}{{/hungry}})" ;
178
- auto result3 = glz::stencil (layout_skip, p3).value_or (" error" );
179
- expect (result3 == " Henry Foster " ) << result3;
169
+ person p3{" Henry" , " Foster" , 34 , true , false };
170
+ std::string_view layout_skip = R"( {{first_name}} {{last_name}} {{^hungry}}I'm not hungry {{^employed}}and not employed{{/employed}}{{/hungry}})" ;
171
+ auto result3 = glz::stencil (layout_skip, p3).value_or (" error" );
172
+ expect (result3 == " Henry Foster " ) << result3;
180
173
};
181
174
182
175
" inverted_section_unknown_key" _test = [] {
@@ -189,8 +182,7 @@ suite mustache_tests = [] {
189
182
};
190
183
191
184
" inverted_section_mismatched_closing_tag" _test = [] {
192
- std::string_view layout =
193
- R"( {{first_name}} {{last_name}} {{^hungry}}I'm not hungry{{/hunger}})" ; // Mismatched closing tag
185
+ std::string_view layout = R"( {{first_name}} {{last_name}} {{^hungry}}I'm not hungry{{/hunger}})" ; // Mismatched closing tag
194
186
195
187
person p{" Henry" , " Foster" , 34 , false };
196
188
auto result = glz::stencil (layout, p);
0 commit comments