1*11be35a1SLionel Sambuc // Copyright 2012 Google Inc.
2*11be35a1SLionel Sambuc // All rights reserved.
3*11be35a1SLionel Sambuc //
4*11be35a1SLionel Sambuc // Redistribution and use in source and binary forms, with or without
5*11be35a1SLionel Sambuc // modification, are permitted provided that the following conditions are
6*11be35a1SLionel Sambuc // met:
7*11be35a1SLionel Sambuc //
8*11be35a1SLionel Sambuc // * Redistributions of source code must retain the above copyright
9*11be35a1SLionel Sambuc // notice, this list of conditions and the following disclaimer.
10*11be35a1SLionel Sambuc // * Redistributions in binary form must reproduce the above copyright
11*11be35a1SLionel Sambuc // notice, this list of conditions and the following disclaimer in the
12*11be35a1SLionel Sambuc // documentation and/or other materials provided with the distribution.
13*11be35a1SLionel Sambuc // * Neither the name of Google Inc. nor the names of its contributors
14*11be35a1SLionel Sambuc // may be used to endorse or promote products derived from this software
15*11be35a1SLionel Sambuc // without specific prior written permission.
16*11be35a1SLionel Sambuc //
17*11be35a1SLionel Sambuc // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18*11be35a1SLionel Sambuc // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19*11be35a1SLionel Sambuc // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20*11be35a1SLionel Sambuc // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21*11be35a1SLionel Sambuc // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22*11be35a1SLionel Sambuc // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23*11be35a1SLionel Sambuc // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24*11be35a1SLionel Sambuc // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25*11be35a1SLionel Sambuc // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26*11be35a1SLionel Sambuc // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27*11be35a1SLionel Sambuc // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*11be35a1SLionel Sambuc
29*11be35a1SLionel Sambuc #include "utils/text/templates.hpp"
30*11be35a1SLionel Sambuc
31*11be35a1SLionel Sambuc #include <fstream>
32*11be35a1SLionel Sambuc #include <sstream>
33*11be35a1SLionel Sambuc
34*11be35a1SLionel Sambuc #include <atf-c++.hpp>
35*11be35a1SLionel Sambuc
36*11be35a1SLionel Sambuc #include "utils/fs/operations.hpp"
37*11be35a1SLionel Sambuc #include "utils/fs/path.hpp"
38*11be35a1SLionel Sambuc #include "utils/text/exceptions.hpp"
39*11be35a1SLionel Sambuc
40*11be35a1SLionel Sambuc namespace fs = utils::fs;
41*11be35a1SLionel Sambuc namespace text = utils::text;
42*11be35a1SLionel Sambuc
43*11be35a1SLionel Sambuc
44*11be35a1SLionel Sambuc namespace {
45*11be35a1SLionel Sambuc
46*11be35a1SLionel Sambuc
47*11be35a1SLionel Sambuc /// Applies a set of templates to an input string and validates the output.
48*11be35a1SLionel Sambuc ///
49*11be35a1SLionel Sambuc /// This fails the test case if exp_output does not match the document generated
50*11be35a1SLionel Sambuc /// by the application of the templates.
51*11be35a1SLionel Sambuc ///
52*11be35a1SLionel Sambuc /// \param templates The templates to apply.
53*11be35a1SLionel Sambuc /// \param input_str The input document to which to apply the templates.
54*11be35a1SLionel Sambuc /// \param exp_output The expected output document.
55*11be35a1SLionel Sambuc static void
do_test_ok(const text::templates_def & templates,const std::string & input_str,const std::string & exp_output)56*11be35a1SLionel Sambuc do_test_ok(const text::templates_def& templates, const std::string& input_str,
57*11be35a1SLionel Sambuc const std::string& exp_output)
58*11be35a1SLionel Sambuc {
59*11be35a1SLionel Sambuc std::istringstream input(input_str);
60*11be35a1SLionel Sambuc std::ostringstream output;
61*11be35a1SLionel Sambuc
62*11be35a1SLionel Sambuc text::instantiate(templates, input, output);
63*11be35a1SLionel Sambuc ATF_REQUIRE_EQ(exp_output, output.str());
64*11be35a1SLionel Sambuc }
65*11be35a1SLionel Sambuc
66*11be35a1SLionel Sambuc
67*11be35a1SLionel Sambuc /// Applies a set of templates to an input string and checks for an error.
68*11be35a1SLionel Sambuc ///
69*11be35a1SLionel Sambuc /// This fails the test case if the exception raised by the template processing
70*11be35a1SLionel Sambuc /// does not match the expected message.
71*11be35a1SLionel Sambuc ///
72*11be35a1SLionel Sambuc /// \param templates The templates to apply.
73*11be35a1SLionel Sambuc /// \param input_str The input document to which to apply the templates.
74*11be35a1SLionel Sambuc /// \param exp_message The expected error message in the raised exception.
75*11be35a1SLionel Sambuc static void
do_test_fail(const text::templates_def & templates,const std::string & input_str,const std::string & exp_message)76*11be35a1SLionel Sambuc do_test_fail(const text::templates_def& templates, const std::string& input_str,
77*11be35a1SLionel Sambuc const std::string& exp_message)
78*11be35a1SLionel Sambuc {
79*11be35a1SLionel Sambuc std::istringstream input(input_str);
80*11be35a1SLionel Sambuc std::ostringstream output;
81*11be35a1SLionel Sambuc
82*11be35a1SLionel Sambuc ATF_REQUIRE_THROW_RE(text::syntax_error, exp_message,
83*11be35a1SLionel Sambuc text::instantiate(templates, input, output));
84*11be35a1SLionel Sambuc }
85*11be35a1SLionel Sambuc
86*11be35a1SLionel Sambuc
87*11be35a1SLionel Sambuc } // anonymous namespace
88*11be35a1SLionel Sambuc
89*11be35a1SLionel Sambuc
90*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__add_variable__first);
ATF_TEST_CASE_BODY(templates_def__add_variable__first)91*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__add_variable__first)
92*11be35a1SLionel Sambuc {
93*11be35a1SLionel Sambuc text::templates_def templates;
94*11be35a1SLionel Sambuc templates.add_variable("the-name", "first-value");
95*11be35a1SLionel Sambuc ATF_REQUIRE_EQ("first-value", templates.get_variable("the-name"));
96*11be35a1SLionel Sambuc }
97*11be35a1SLionel Sambuc
98*11be35a1SLionel Sambuc
99*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__add_variable__replace);
ATF_TEST_CASE_BODY(templates_def__add_variable__replace)100*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__add_variable__replace)
101*11be35a1SLionel Sambuc {
102*11be35a1SLionel Sambuc text::templates_def templates;
103*11be35a1SLionel Sambuc templates.add_variable("the-name", "first-value");
104*11be35a1SLionel Sambuc templates.add_variable("the-name", "second-value");
105*11be35a1SLionel Sambuc ATF_REQUIRE_EQ("second-value", templates.get_variable("the-name"));
106*11be35a1SLionel Sambuc }
107*11be35a1SLionel Sambuc
108*11be35a1SLionel Sambuc
109*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__remove_variable);
ATF_TEST_CASE_BODY(templates_def__remove_variable)110*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__remove_variable)
111*11be35a1SLionel Sambuc {
112*11be35a1SLionel Sambuc text::templates_def templates;
113*11be35a1SLionel Sambuc templates.add_variable("the-name", "the-value");
114*11be35a1SLionel Sambuc templates.get_variable("the-name"); // Should not throw.
115*11be35a1SLionel Sambuc templates.remove_variable("the-name");
116*11be35a1SLionel Sambuc ATF_REQUIRE_THROW(text::syntax_error, templates.get_variable("the-name"));
117*11be35a1SLionel Sambuc }
118*11be35a1SLionel Sambuc
119*11be35a1SLionel Sambuc
120*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__add_vector__first);
ATF_TEST_CASE_BODY(templates_def__add_vector__first)121*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__add_vector__first)
122*11be35a1SLionel Sambuc {
123*11be35a1SLionel Sambuc text::templates_def templates;
124*11be35a1SLionel Sambuc templates.add_vector("the-name");
125*11be35a1SLionel Sambuc ATF_REQUIRE(templates.get_vector("the-name").empty());
126*11be35a1SLionel Sambuc }
127*11be35a1SLionel Sambuc
128*11be35a1SLionel Sambuc
129*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__add_vector__replace);
ATF_TEST_CASE_BODY(templates_def__add_vector__replace)130*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__add_vector__replace)
131*11be35a1SLionel Sambuc {
132*11be35a1SLionel Sambuc text::templates_def templates;
133*11be35a1SLionel Sambuc templates.add_vector("the-name");
134*11be35a1SLionel Sambuc templates.add_to_vector("the-name", "foo");
135*11be35a1SLionel Sambuc ATF_REQUIRE(!templates.get_vector("the-name").empty());
136*11be35a1SLionel Sambuc templates.add_vector("the-name");
137*11be35a1SLionel Sambuc ATF_REQUIRE(templates.get_vector("the-name").empty());
138*11be35a1SLionel Sambuc }
139*11be35a1SLionel Sambuc
140*11be35a1SLionel Sambuc
141*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__add_to_vector);
ATF_TEST_CASE_BODY(templates_def__add_to_vector)142*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__add_to_vector)
143*11be35a1SLionel Sambuc {
144*11be35a1SLionel Sambuc text::templates_def templates;
145*11be35a1SLionel Sambuc templates.add_vector("the-name");
146*11be35a1SLionel Sambuc ATF_REQUIRE_EQ(0, templates.get_vector("the-name").size());
147*11be35a1SLionel Sambuc templates.add_to_vector("the-name", "first");
148*11be35a1SLionel Sambuc ATF_REQUIRE_EQ(1, templates.get_vector("the-name").size());
149*11be35a1SLionel Sambuc templates.add_to_vector("the-name", "second");
150*11be35a1SLionel Sambuc ATF_REQUIRE_EQ(2, templates.get_vector("the-name").size());
151*11be35a1SLionel Sambuc templates.add_to_vector("the-name", "third");
152*11be35a1SLionel Sambuc ATF_REQUIRE_EQ(3, templates.get_vector("the-name").size());
153*11be35a1SLionel Sambuc
154*11be35a1SLionel Sambuc std::vector< std::string > expected;
155*11be35a1SLionel Sambuc expected.push_back("first");
156*11be35a1SLionel Sambuc expected.push_back("second");
157*11be35a1SLionel Sambuc expected.push_back("third");
158*11be35a1SLionel Sambuc ATF_REQUIRE(expected == templates.get_vector("the-name"));
159*11be35a1SLionel Sambuc }
160*11be35a1SLionel Sambuc
161*11be35a1SLionel Sambuc
162*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__exists__variable);
ATF_TEST_CASE_BODY(templates_def__exists__variable)163*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__exists__variable)
164*11be35a1SLionel Sambuc {
165*11be35a1SLionel Sambuc text::templates_def templates;
166*11be35a1SLionel Sambuc ATF_REQUIRE(!templates.exists("some-name"));
167*11be35a1SLionel Sambuc templates.add_variable("some-name ", "foo");
168*11be35a1SLionel Sambuc ATF_REQUIRE(!templates.exists("some-name"));
169*11be35a1SLionel Sambuc templates.add_variable("some-name", "foo");
170*11be35a1SLionel Sambuc ATF_REQUIRE(templates.exists("some-name"));
171*11be35a1SLionel Sambuc }
172*11be35a1SLionel Sambuc
173*11be35a1SLionel Sambuc
174*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__exists__vector);
ATF_TEST_CASE_BODY(templates_def__exists__vector)175*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__exists__vector)
176*11be35a1SLionel Sambuc {
177*11be35a1SLionel Sambuc text::templates_def templates;
178*11be35a1SLionel Sambuc ATF_REQUIRE(!templates.exists("some-name"));
179*11be35a1SLionel Sambuc templates.add_vector("some-name ");
180*11be35a1SLionel Sambuc ATF_REQUIRE(!templates.exists("some-name"));
181*11be35a1SLionel Sambuc templates.add_vector("some-name");
182*11be35a1SLionel Sambuc ATF_REQUIRE(templates.exists("some-name"));
183*11be35a1SLionel Sambuc }
184*11be35a1SLionel Sambuc
185*11be35a1SLionel Sambuc
186*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__get_variable__ok);
ATF_TEST_CASE_BODY(templates_def__get_variable__ok)187*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__get_variable__ok)
188*11be35a1SLionel Sambuc {
189*11be35a1SLionel Sambuc text::templates_def templates;
190*11be35a1SLionel Sambuc templates.add_variable("foo", "");
191*11be35a1SLionel Sambuc templates.add_variable("bar", " baz ");
192*11be35a1SLionel Sambuc ATF_REQUIRE_EQ("", templates.get_variable("foo"));
193*11be35a1SLionel Sambuc ATF_REQUIRE_EQ(" baz ", templates.get_variable("bar"));
194*11be35a1SLionel Sambuc }
195*11be35a1SLionel Sambuc
196*11be35a1SLionel Sambuc
197*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__get_variable__unknown);
ATF_TEST_CASE_BODY(templates_def__get_variable__unknown)198*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__get_variable__unknown)
199*11be35a1SLionel Sambuc {
200*11be35a1SLionel Sambuc text::templates_def templates;
201*11be35a1SLionel Sambuc templates.add_variable("foo", "");
202*11be35a1SLionel Sambuc ATF_REQUIRE_THROW_RE(text::syntax_error, "Unknown variable 'foo '",
203*11be35a1SLionel Sambuc templates.get_variable("foo "));
204*11be35a1SLionel Sambuc }
205*11be35a1SLionel Sambuc
206*11be35a1SLionel Sambuc
207*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__get_vector__ok);
ATF_TEST_CASE_BODY(templates_def__get_vector__ok)208*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__get_vector__ok)
209*11be35a1SLionel Sambuc {
210*11be35a1SLionel Sambuc text::templates_def templates;
211*11be35a1SLionel Sambuc templates.add_vector("foo");
212*11be35a1SLionel Sambuc templates.add_vector("bar");
213*11be35a1SLionel Sambuc templates.add_to_vector("bar", "baz");
214*11be35a1SLionel Sambuc ATF_REQUIRE_EQ(0, templates.get_vector("foo").size());
215*11be35a1SLionel Sambuc ATF_REQUIRE_EQ(1, templates.get_vector("bar").size());
216*11be35a1SLionel Sambuc }
217*11be35a1SLionel Sambuc
218*11be35a1SLionel Sambuc
219*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__get_vector__unknown);
ATF_TEST_CASE_BODY(templates_def__get_vector__unknown)220*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__get_vector__unknown)
221*11be35a1SLionel Sambuc {
222*11be35a1SLionel Sambuc text::templates_def templates;
223*11be35a1SLionel Sambuc templates.add_vector("foo");
224*11be35a1SLionel Sambuc ATF_REQUIRE_THROW_RE(text::syntax_error, "Unknown vector 'foo '",
225*11be35a1SLionel Sambuc templates.get_vector("foo "));
226*11be35a1SLionel Sambuc }
227*11be35a1SLionel Sambuc
228*11be35a1SLionel Sambuc
229*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__evaluate__variable__ok);
ATF_TEST_CASE_BODY(templates_def__evaluate__variable__ok)230*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__evaluate__variable__ok)
231*11be35a1SLionel Sambuc {
232*11be35a1SLionel Sambuc text::templates_def templates;
233*11be35a1SLionel Sambuc templates.add_variable("foo", "");
234*11be35a1SLionel Sambuc templates.add_variable("bar", " baz ");
235*11be35a1SLionel Sambuc ATF_REQUIRE_EQ("", templates.evaluate("foo"));
236*11be35a1SLionel Sambuc ATF_REQUIRE_EQ(" baz ", templates.evaluate("bar"));
237*11be35a1SLionel Sambuc }
238*11be35a1SLionel Sambuc
239*11be35a1SLionel Sambuc
240*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__evaluate__variable__unknown);
ATF_TEST_CASE_BODY(templates_def__evaluate__variable__unknown)241*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__evaluate__variable__unknown)
242*11be35a1SLionel Sambuc {
243*11be35a1SLionel Sambuc text::templates_def templates;
244*11be35a1SLionel Sambuc templates.add_variable("foo", "");
245*11be35a1SLionel Sambuc ATF_REQUIRE_THROW_RE(text::syntax_error, "Unknown variable 'foo1'",
246*11be35a1SLionel Sambuc templates.evaluate("foo1"));
247*11be35a1SLionel Sambuc }
248*11be35a1SLionel Sambuc
249*11be35a1SLionel Sambuc
250*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__evaluate__vector__ok);
ATF_TEST_CASE_BODY(templates_def__evaluate__vector__ok)251*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__evaluate__vector__ok)
252*11be35a1SLionel Sambuc {
253*11be35a1SLionel Sambuc text::templates_def templates;
254*11be35a1SLionel Sambuc templates.add_vector("v");
255*11be35a1SLionel Sambuc templates.add_to_vector("v", "foo");
256*11be35a1SLionel Sambuc templates.add_to_vector("v", "bar");
257*11be35a1SLionel Sambuc templates.add_to_vector("v", "baz");
258*11be35a1SLionel Sambuc
259*11be35a1SLionel Sambuc templates.add_variable("index", "0");
260*11be35a1SLionel Sambuc ATF_REQUIRE_EQ("foo", templates.evaluate("v(index)"));
261*11be35a1SLionel Sambuc templates.add_variable("index", "1");
262*11be35a1SLionel Sambuc ATF_REQUIRE_EQ("bar", templates.evaluate("v(index)"));
263*11be35a1SLionel Sambuc templates.add_variable("index", "2");
264*11be35a1SLionel Sambuc ATF_REQUIRE_EQ("baz", templates.evaluate("v(index)"));
265*11be35a1SLionel Sambuc }
266*11be35a1SLionel Sambuc
267*11be35a1SLionel Sambuc
268*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__evaluate__vector__unknown_vector);
ATF_TEST_CASE_BODY(templates_def__evaluate__vector__unknown_vector)269*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__evaluate__vector__unknown_vector)
270*11be35a1SLionel Sambuc {
271*11be35a1SLionel Sambuc text::templates_def templates;
272*11be35a1SLionel Sambuc templates.add_vector("v");
273*11be35a1SLionel Sambuc templates.add_to_vector("v", "foo");
274*11be35a1SLionel Sambuc templates.add_variable("index", "0");
275*11be35a1SLionel Sambuc ATF_REQUIRE_THROW_RE(text::syntax_error, "Unknown vector 'fooz'",
276*11be35a1SLionel Sambuc templates.evaluate("fooz(index)"));
277*11be35a1SLionel Sambuc }
278*11be35a1SLionel Sambuc
279*11be35a1SLionel Sambuc
280*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__evaluate__vector__unknown_index);
ATF_TEST_CASE_BODY(templates_def__evaluate__vector__unknown_index)281*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__evaluate__vector__unknown_index)
282*11be35a1SLionel Sambuc {
283*11be35a1SLionel Sambuc text::templates_def templates;
284*11be35a1SLionel Sambuc templates.add_vector("v");
285*11be35a1SLionel Sambuc templates.add_to_vector("v", "foo");
286*11be35a1SLionel Sambuc templates.add_variable("index", "0");
287*11be35a1SLionel Sambuc ATF_REQUIRE_THROW_RE(text::syntax_error, "Unknown variable 'indexz'",
288*11be35a1SLionel Sambuc templates.evaluate("v(indexz)"));
289*11be35a1SLionel Sambuc }
290*11be35a1SLionel Sambuc
291*11be35a1SLionel Sambuc
292*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__evaluate__vector__out_of_range);
ATF_TEST_CASE_BODY(templates_def__evaluate__vector__out_of_range)293*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__evaluate__vector__out_of_range)
294*11be35a1SLionel Sambuc {
295*11be35a1SLionel Sambuc text::templates_def templates;
296*11be35a1SLionel Sambuc templates.add_vector("v");
297*11be35a1SLionel Sambuc templates.add_to_vector("v", "foo");
298*11be35a1SLionel Sambuc templates.add_variable("index", "1");
299*11be35a1SLionel Sambuc ATF_REQUIRE_THROW_RE(text::syntax_error, "Index 'index' out of range "
300*11be35a1SLionel Sambuc "at position '1'", templates.evaluate("v(index)"));
301*11be35a1SLionel Sambuc }
302*11be35a1SLionel Sambuc
303*11be35a1SLionel Sambuc
304*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__evaluate__defined);
ATF_TEST_CASE_BODY(templates_def__evaluate__defined)305*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__evaluate__defined)
306*11be35a1SLionel Sambuc {
307*11be35a1SLionel Sambuc text::templates_def templates;
308*11be35a1SLionel Sambuc templates.add_vector("the-variable");
309*11be35a1SLionel Sambuc templates.add_vector("the-vector");
310*11be35a1SLionel Sambuc ATF_REQUIRE_EQ("false", templates.evaluate("defined(the-variabl)"));
311*11be35a1SLionel Sambuc ATF_REQUIRE_EQ("false", templates.evaluate("defined(the-vecto)"));
312*11be35a1SLionel Sambuc ATF_REQUIRE_EQ("true", templates.evaluate("defined(the-variable)"));
313*11be35a1SLionel Sambuc ATF_REQUIRE_EQ("true", templates.evaluate("defined(the-vector)"));
314*11be35a1SLionel Sambuc }
315*11be35a1SLionel Sambuc
316*11be35a1SLionel Sambuc
317*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__evaluate__length__ok);
ATF_TEST_CASE_BODY(templates_def__evaluate__length__ok)318*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__evaluate__length__ok)
319*11be35a1SLionel Sambuc {
320*11be35a1SLionel Sambuc text::templates_def templates;
321*11be35a1SLionel Sambuc templates.add_vector("v");
322*11be35a1SLionel Sambuc ATF_REQUIRE_EQ("0", templates.evaluate("length(v)"));
323*11be35a1SLionel Sambuc templates.add_to_vector("v", "foo");
324*11be35a1SLionel Sambuc ATF_REQUIRE_EQ("1", templates.evaluate("length(v)"));
325*11be35a1SLionel Sambuc templates.add_to_vector("v", "bar");
326*11be35a1SLionel Sambuc ATF_REQUIRE_EQ("2", templates.evaluate("length(v)"));
327*11be35a1SLionel Sambuc templates.add_to_vector("v", "baz");
328*11be35a1SLionel Sambuc ATF_REQUIRE_EQ("3", templates.evaluate("length(v)"));
329*11be35a1SLionel Sambuc }
330*11be35a1SLionel Sambuc
331*11be35a1SLionel Sambuc
332*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__evaluate__length__unknown_vector);
ATF_TEST_CASE_BODY(templates_def__evaluate__length__unknown_vector)333*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__evaluate__length__unknown_vector)
334*11be35a1SLionel Sambuc {
335*11be35a1SLionel Sambuc text::templates_def templates;
336*11be35a1SLionel Sambuc templates.add_vector("foo1");
337*11be35a1SLionel Sambuc ATF_REQUIRE_THROW_RE(text::syntax_error, "Unknown vector 'foo'",
338*11be35a1SLionel Sambuc templates.evaluate("length(foo)"));
339*11be35a1SLionel Sambuc }
340*11be35a1SLionel Sambuc
341*11be35a1SLionel Sambuc
342*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(templates_def__evaluate__parenthesis_error);
ATF_TEST_CASE_BODY(templates_def__evaluate__parenthesis_error)343*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(templates_def__evaluate__parenthesis_error)
344*11be35a1SLionel Sambuc {
345*11be35a1SLionel Sambuc text::templates_def templates;
346*11be35a1SLionel Sambuc ATF_REQUIRE_THROW_RE(text::syntax_error,
347*11be35a1SLionel Sambuc "Expected '\\)' in.*'foo\\(abc'",
348*11be35a1SLionel Sambuc templates.evaluate("foo(abc"));
349*11be35a1SLionel Sambuc ATF_REQUIRE_THROW_RE(text::syntax_error,
350*11be35a1SLionel Sambuc "Unexpected text.*'\\)' in.*'a\\(b\\)c'",
351*11be35a1SLionel Sambuc templates.evaluate("a(b)c"));
352*11be35a1SLionel Sambuc }
353*11be35a1SLionel Sambuc
354*11be35a1SLionel Sambuc
355*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__empty_input);
ATF_TEST_CASE_BODY(instantiate__empty_input)356*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__empty_input)
357*11be35a1SLionel Sambuc {
358*11be35a1SLionel Sambuc const text::templates_def templates;
359*11be35a1SLionel Sambuc do_test_ok(templates, "", "");
360*11be35a1SLionel Sambuc }
361*11be35a1SLionel Sambuc
362*11be35a1SLionel Sambuc
363*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__value__ok);
ATF_TEST_CASE_BODY(instantiate__value__ok)364*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__value__ok)
365*11be35a1SLionel Sambuc {
366*11be35a1SLionel Sambuc const std::string input =
367*11be35a1SLionel Sambuc "first line\n"
368*11be35a1SLionel Sambuc "%%testvar1%%\n"
369*11be35a1SLionel Sambuc "third line\n"
370*11be35a1SLionel Sambuc "%%testvar2%% %%testvar3%%%%testvar4%%\n"
371*11be35a1SLionel Sambuc "fifth line\n";
372*11be35a1SLionel Sambuc
373*11be35a1SLionel Sambuc const std::string exp_output =
374*11be35a1SLionel Sambuc "first line\n"
375*11be35a1SLionel Sambuc "second line\n"
376*11be35a1SLionel Sambuc "third line\n"
377*11be35a1SLionel Sambuc "fourth line.\n"
378*11be35a1SLionel Sambuc "fifth line\n";
379*11be35a1SLionel Sambuc
380*11be35a1SLionel Sambuc text::templates_def templates;
381*11be35a1SLionel Sambuc templates.add_variable("testvar1", "second line");
382*11be35a1SLionel Sambuc templates.add_variable("testvar2", "fourth");
383*11be35a1SLionel Sambuc templates.add_variable("testvar3", "line");
384*11be35a1SLionel Sambuc templates.add_variable("testvar4", ".");
385*11be35a1SLionel Sambuc
386*11be35a1SLionel Sambuc do_test_ok(templates, input, exp_output);
387*11be35a1SLionel Sambuc }
388*11be35a1SLionel Sambuc
389*11be35a1SLionel Sambuc
390*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__value__unknown_variable);
ATF_TEST_CASE_BODY(instantiate__value__unknown_variable)391*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__value__unknown_variable)
392*11be35a1SLionel Sambuc {
393*11be35a1SLionel Sambuc const std::string input =
394*11be35a1SLionel Sambuc "%%testvar1%%\n";
395*11be35a1SLionel Sambuc
396*11be35a1SLionel Sambuc text::templates_def templates;
397*11be35a1SLionel Sambuc templates.add_variable("testvar2", "fourth line");
398*11be35a1SLionel Sambuc
399*11be35a1SLionel Sambuc do_test_fail(templates, input, "Unknown variable 'testvar1'");
400*11be35a1SLionel Sambuc }
401*11be35a1SLionel Sambuc
402*11be35a1SLionel Sambuc
403*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__vector_length__ok);
ATF_TEST_CASE_BODY(instantiate__vector_length__ok)404*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__vector_length__ok)
405*11be35a1SLionel Sambuc {
406*11be35a1SLionel Sambuc const std::string input =
407*11be35a1SLionel Sambuc "%%length(testvector1)%%\n"
408*11be35a1SLionel Sambuc "%%length(testvector2)%% - %%length(testvector3)%%\n";
409*11be35a1SLionel Sambuc
410*11be35a1SLionel Sambuc const std::string exp_output =
411*11be35a1SLionel Sambuc "4\n"
412*11be35a1SLionel Sambuc "0 - 1\n";
413*11be35a1SLionel Sambuc
414*11be35a1SLionel Sambuc text::templates_def templates;
415*11be35a1SLionel Sambuc templates.add_vector("testvector1");
416*11be35a1SLionel Sambuc templates.add_to_vector("testvector1", "000");
417*11be35a1SLionel Sambuc templates.add_to_vector("testvector1", "111");
418*11be35a1SLionel Sambuc templates.add_to_vector("testvector1", "543");
419*11be35a1SLionel Sambuc templates.add_to_vector("testvector1", "999");
420*11be35a1SLionel Sambuc templates.add_vector("testvector2");
421*11be35a1SLionel Sambuc templates.add_vector("testvector3");
422*11be35a1SLionel Sambuc templates.add_to_vector("testvector3", "123");
423*11be35a1SLionel Sambuc
424*11be35a1SLionel Sambuc do_test_ok(templates, input, exp_output);
425*11be35a1SLionel Sambuc }
426*11be35a1SLionel Sambuc
427*11be35a1SLionel Sambuc
428*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__vector_length__unknown_vector);
ATF_TEST_CASE_BODY(instantiate__vector_length__unknown_vector)429*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__vector_length__unknown_vector)
430*11be35a1SLionel Sambuc {
431*11be35a1SLionel Sambuc const std::string input =
432*11be35a1SLionel Sambuc "%%length(testvector)%%\n";
433*11be35a1SLionel Sambuc
434*11be35a1SLionel Sambuc text::templates_def templates;
435*11be35a1SLionel Sambuc templates.add_vector("testvector2");
436*11be35a1SLionel Sambuc
437*11be35a1SLionel Sambuc do_test_fail(templates, input, "Unknown vector 'testvector'");
438*11be35a1SLionel Sambuc }
439*11be35a1SLionel Sambuc
440*11be35a1SLionel Sambuc
441*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__vector_value__ok);
ATF_TEST_CASE_BODY(instantiate__vector_value__ok)442*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__vector_value__ok)
443*11be35a1SLionel Sambuc {
444*11be35a1SLionel Sambuc const std::string input =
445*11be35a1SLionel Sambuc "first line\n"
446*11be35a1SLionel Sambuc "%%testvector1(i)%%\n"
447*11be35a1SLionel Sambuc "third line\n"
448*11be35a1SLionel Sambuc "%%testvector2(j)%%\n"
449*11be35a1SLionel Sambuc "fifth line\n";
450*11be35a1SLionel Sambuc
451*11be35a1SLionel Sambuc const std::string exp_output =
452*11be35a1SLionel Sambuc "first line\n"
453*11be35a1SLionel Sambuc "543\n"
454*11be35a1SLionel Sambuc "third line\n"
455*11be35a1SLionel Sambuc "123\n"
456*11be35a1SLionel Sambuc "fifth line\n";
457*11be35a1SLionel Sambuc
458*11be35a1SLionel Sambuc text::templates_def templates;
459*11be35a1SLionel Sambuc templates.add_variable("i", "2");
460*11be35a1SLionel Sambuc templates.add_variable("j", "0");
461*11be35a1SLionel Sambuc templates.add_vector("testvector1");
462*11be35a1SLionel Sambuc templates.add_to_vector("testvector1", "000");
463*11be35a1SLionel Sambuc templates.add_to_vector("testvector1", "111");
464*11be35a1SLionel Sambuc templates.add_to_vector("testvector1", "543");
465*11be35a1SLionel Sambuc templates.add_to_vector("testvector1", "999");
466*11be35a1SLionel Sambuc templates.add_vector("testvector2");
467*11be35a1SLionel Sambuc templates.add_to_vector("testvector2", "123");
468*11be35a1SLionel Sambuc
469*11be35a1SLionel Sambuc do_test_ok(templates, input, exp_output);
470*11be35a1SLionel Sambuc }
471*11be35a1SLionel Sambuc
472*11be35a1SLionel Sambuc
473*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__vector_value__unknown_vector);
ATF_TEST_CASE_BODY(instantiate__vector_value__unknown_vector)474*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__vector_value__unknown_vector)
475*11be35a1SLionel Sambuc {
476*11be35a1SLionel Sambuc const std::string input =
477*11be35a1SLionel Sambuc "%%testvector(j)%%\n";
478*11be35a1SLionel Sambuc
479*11be35a1SLionel Sambuc text::templates_def templates;
480*11be35a1SLionel Sambuc templates.add_vector("testvector2");
481*11be35a1SLionel Sambuc
482*11be35a1SLionel Sambuc do_test_fail(templates, input, "Unknown vector 'testvector'");
483*11be35a1SLionel Sambuc }
484*11be35a1SLionel Sambuc
485*11be35a1SLionel Sambuc
486*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__vector_value__out_of_range__empty);
ATF_TEST_CASE_BODY(instantiate__vector_value__out_of_range__empty)487*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__vector_value__out_of_range__empty)
488*11be35a1SLionel Sambuc {
489*11be35a1SLionel Sambuc const std::string input =
490*11be35a1SLionel Sambuc "%%testvector(j)%%\n";
491*11be35a1SLionel Sambuc
492*11be35a1SLionel Sambuc text::templates_def templates;
493*11be35a1SLionel Sambuc templates.add_vector("testvector");
494*11be35a1SLionel Sambuc templates.add_variable("j", "0");
495*11be35a1SLionel Sambuc
496*11be35a1SLionel Sambuc do_test_fail(templates, input, "Index 'j' out of range at position '0'");
497*11be35a1SLionel Sambuc }
498*11be35a1SLionel Sambuc
499*11be35a1SLionel Sambuc
500*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__vector_value__out_of_range__not_empty);
ATF_TEST_CASE_BODY(instantiate__vector_value__out_of_range__not_empty)501*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__vector_value__out_of_range__not_empty)
502*11be35a1SLionel Sambuc {
503*11be35a1SLionel Sambuc const std::string input =
504*11be35a1SLionel Sambuc "%%testvector(j)%%\n";
505*11be35a1SLionel Sambuc
506*11be35a1SLionel Sambuc text::templates_def templates;
507*11be35a1SLionel Sambuc templates.add_vector("testvector");
508*11be35a1SLionel Sambuc templates.add_to_vector("testvector", "a");
509*11be35a1SLionel Sambuc templates.add_to_vector("testvector", "b");
510*11be35a1SLionel Sambuc templates.add_variable("j", "2");
511*11be35a1SLionel Sambuc
512*11be35a1SLionel Sambuc do_test_fail(templates, input, "Index 'j' out of range at position '2'");
513*11be35a1SLionel Sambuc }
514*11be35a1SLionel Sambuc
515*11be35a1SLionel Sambuc
516*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__if__one_level__taken);
ATF_TEST_CASE_BODY(instantiate__if__one_level__taken)517*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__if__one_level__taken)
518*11be35a1SLionel Sambuc {
519*11be35a1SLionel Sambuc const std::string input =
520*11be35a1SLionel Sambuc "first line\n"
521*11be35a1SLionel Sambuc "%if defined(some_var)\n"
522*11be35a1SLionel Sambuc "hello from within the variable conditional\n"
523*11be35a1SLionel Sambuc "%endif\n"
524*11be35a1SLionel Sambuc "%if defined(some_vector)\n"
525*11be35a1SLionel Sambuc "hello from within the vector conditional\n"
526*11be35a1SLionel Sambuc "%else\n"
527*11be35a1SLionel Sambuc "bye from within the vector conditional\n"
528*11be35a1SLionel Sambuc "%endif\n"
529*11be35a1SLionel Sambuc "some more\n";
530*11be35a1SLionel Sambuc
531*11be35a1SLionel Sambuc const std::string exp_output =
532*11be35a1SLionel Sambuc "first line\n"
533*11be35a1SLionel Sambuc "hello from within the variable conditional\n"
534*11be35a1SLionel Sambuc "hello from within the vector conditional\n"
535*11be35a1SLionel Sambuc "some more\n";
536*11be35a1SLionel Sambuc
537*11be35a1SLionel Sambuc text::templates_def templates;
538*11be35a1SLionel Sambuc templates.add_variable("some_var", "zzz");
539*11be35a1SLionel Sambuc templates.add_vector("some_vector");
540*11be35a1SLionel Sambuc
541*11be35a1SLionel Sambuc do_test_ok(templates, input, exp_output);
542*11be35a1SLionel Sambuc }
543*11be35a1SLionel Sambuc
544*11be35a1SLionel Sambuc
545*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__if__one_level__not_taken);
ATF_TEST_CASE_BODY(instantiate__if__one_level__not_taken)546*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__if__one_level__not_taken)
547*11be35a1SLionel Sambuc {
548*11be35a1SLionel Sambuc const std::string input =
549*11be35a1SLionel Sambuc "first line\n"
550*11be35a1SLionel Sambuc "%if defined(some_var)\n"
551*11be35a1SLionel Sambuc "hello from within the variable conditional\n"
552*11be35a1SLionel Sambuc "%endif\n"
553*11be35a1SLionel Sambuc "%if defined(some_vector)\n"
554*11be35a1SLionel Sambuc "hello from within the vector conditional\n"
555*11be35a1SLionel Sambuc "%else\n"
556*11be35a1SLionel Sambuc "bye from within the vector conditional\n"
557*11be35a1SLionel Sambuc "%endif\n"
558*11be35a1SLionel Sambuc "some more\n";
559*11be35a1SLionel Sambuc
560*11be35a1SLionel Sambuc const std::string exp_output =
561*11be35a1SLionel Sambuc "first line\n"
562*11be35a1SLionel Sambuc "bye from within the vector conditional\n"
563*11be35a1SLionel Sambuc "some more\n";
564*11be35a1SLionel Sambuc
565*11be35a1SLionel Sambuc text::templates_def templates;
566*11be35a1SLionel Sambuc
567*11be35a1SLionel Sambuc do_test_ok(templates, input, exp_output);
568*11be35a1SLionel Sambuc }
569*11be35a1SLionel Sambuc
570*11be35a1SLionel Sambuc
571*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__if__multiple_levels__taken);
ATF_TEST_CASE_BODY(instantiate__if__multiple_levels__taken)572*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__if__multiple_levels__taken)
573*11be35a1SLionel Sambuc {
574*11be35a1SLionel Sambuc const std::string input =
575*11be35a1SLionel Sambuc "first line\n"
576*11be35a1SLionel Sambuc "%if defined(var1)\n"
577*11be35a1SLionel Sambuc "first before\n"
578*11be35a1SLionel Sambuc "%if length(var2)\n"
579*11be35a1SLionel Sambuc "second before\n"
580*11be35a1SLionel Sambuc "%if defined(var3)\n"
581*11be35a1SLionel Sambuc "third before\n"
582*11be35a1SLionel Sambuc "hello from within the conditional\n"
583*11be35a1SLionel Sambuc "third after\n"
584*11be35a1SLionel Sambuc "%endif\n"
585*11be35a1SLionel Sambuc "second after\n"
586*11be35a1SLionel Sambuc "%else\n"
587*11be35a1SLionel Sambuc "second after not shown\n"
588*11be35a1SLionel Sambuc "%endif\n"
589*11be35a1SLionel Sambuc "first after\n"
590*11be35a1SLionel Sambuc "%endif\n"
591*11be35a1SLionel Sambuc "some more\n";
592*11be35a1SLionel Sambuc
593*11be35a1SLionel Sambuc const std::string exp_output =
594*11be35a1SLionel Sambuc "first line\n"
595*11be35a1SLionel Sambuc "first before\n"
596*11be35a1SLionel Sambuc "second before\n"
597*11be35a1SLionel Sambuc "third before\n"
598*11be35a1SLionel Sambuc "hello from within the conditional\n"
599*11be35a1SLionel Sambuc "third after\n"
600*11be35a1SLionel Sambuc "second after\n"
601*11be35a1SLionel Sambuc "first after\n"
602*11be35a1SLionel Sambuc "some more\n";
603*11be35a1SLionel Sambuc
604*11be35a1SLionel Sambuc text::templates_def templates;
605*11be35a1SLionel Sambuc templates.add_variable("var1", "false");
606*11be35a1SLionel Sambuc templates.add_vector("var2");
607*11be35a1SLionel Sambuc templates.add_to_vector("var2", "not-empty");
608*11be35a1SLionel Sambuc templates.add_variable("var3", "foobar");
609*11be35a1SLionel Sambuc
610*11be35a1SLionel Sambuc do_test_ok(templates, input, exp_output);
611*11be35a1SLionel Sambuc }
612*11be35a1SLionel Sambuc
613*11be35a1SLionel Sambuc
614*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__if__multiple_levels__not_taken);
ATF_TEST_CASE_BODY(instantiate__if__multiple_levels__not_taken)615*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__if__multiple_levels__not_taken)
616*11be35a1SLionel Sambuc {
617*11be35a1SLionel Sambuc const std::string input =
618*11be35a1SLionel Sambuc "first line\n"
619*11be35a1SLionel Sambuc "%if defined(var1)\n"
620*11be35a1SLionel Sambuc "first before\n"
621*11be35a1SLionel Sambuc "%if length(var2)\n"
622*11be35a1SLionel Sambuc "second before\n"
623*11be35a1SLionel Sambuc "%if defined(var3)\n"
624*11be35a1SLionel Sambuc "third before\n"
625*11be35a1SLionel Sambuc "hello from within the conditional\n"
626*11be35a1SLionel Sambuc "third after\n"
627*11be35a1SLionel Sambuc "%else\n"
628*11be35a1SLionel Sambuc "will not be shown either\n"
629*11be35a1SLionel Sambuc "%endif\n"
630*11be35a1SLionel Sambuc "second after\n"
631*11be35a1SLionel Sambuc "%else\n"
632*11be35a1SLionel Sambuc "second after shown\n"
633*11be35a1SLionel Sambuc "%endif\n"
634*11be35a1SLionel Sambuc "first after\n"
635*11be35a1SLionel Sambuc "%endif\n"
636*11be35a1SLionel Sambuc "some more\n";
637*11be35a1SLionel Sambuc
638*11be35a1SLionel Sambuc const std::string exp_output =
639*11be35a1SLionel Sambuc "first line\n"
640*11be35a1SLionel Sambuc "first before\n"
641*11be35a1SLionel Sambuc "second after shown\n"
642*11be35a1SLionel Sambuc "first after\n"
643*11be35a1SLionel Sambuc "some more\n";
644*11be35a1SLionel Sambuc
645*11be35a1SLionel Sambuc text::templates_def templates;
646*11be35a1SLionel Sambuc templates.add_variable("var1", "false");
647*11be35a1SLionel Sambuc templates.add_vector("var2");
648*11be35a1SLionel Sambuc templates.add_vector("var3");
649*11be35a1SLionel Sambuc
650*11be35a1SLionel Sambuc do_test_ok(templates, input, exp_output);
651*11be35a1SLionel Sambuc }
652*11be35a1SLionel Sambuc
653*11be35a1SLionel Sambuc
654*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__loop__no_iterations);
ATF_TEST_CASE_BODY(instantiate__loop__no_iterations)655*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__loop__no_iterations)
656*11be35a1SLionel Sambuc {
657*11be35a1SLionel Sambuc const std::string input =
658*11be35a1SLionel Sambuc "first line\n"
659*11be35a1SLionel Sambuc "%loop table1 i\n"
660*11be35a1SLionel Sambuc "hello\n"
661*11be35a1SLionel Sambuc "value in vector: %%table1(i)%%\n"
662*11be35a1SLionel Sambuc "%if defined(var1)\n" "some other text\n" "%endif\n"
663*11be35a1SLionel Sambuc "%endloop\n"
664*11be35a1SLionel Sambuc "some more\n";
665*11be35a1SLionel Sambuc
666*11be35a1SLionel Sambuc const std::string exp_output =
667*11be35a1SLionel Sambuc "first line\n"
668*11be35a1SLionel Sambuc "some more\n";
669*11be35a1SLionel Sambuc
670*11be35a1SLionel Sambuc text::templates_def templates;
671*11be35a1SLionel Sambuc templates.add_variable("var1", "defined");
672*11be35a1SLionel Sambuc templates.add_vector("table1");
673*11be35a1SLionel Sambuc
674*11be35a1SLionel Sambuc do_test_ok(templates, input, exp_output);
675*11be35a1SLionel Sambuc }
676*11be35a1SLionel Sambuc
677*11be35a1SLionel Sambuc
678*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__loop__multiple_iterations);
ATF_TEST_CASE_BODY(instantiate__loop__multiple_iterations)679*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__loop__multiple_iterations)
680*11be35a1SLionel Sambuc {
681*11be35a1SLionel Sambuc const std::string input =
682*11be35a1SLionel Sambuc "first line\n"
683*11be35a1SLionel Sambuc "%loop table1 i\n"
684*11be35a1SLionel Sambuc "hello %%table1(i)%% %%table2(i)%%\n"
685*11be35a1SLionel Sambuc "%endloop\n"
686*11be35a1SLionel Sambuc "some more\n";
687*11be35a1SLionel Sambuc
688*11be35a1SLionel Sambuc const std::string exp_output =
689*11be35a1SLionel Sambuc "first line\n"
690*11be35a1SLionel Sambuc "hello foo1 foo2\n"
691*11be35a1SLionel Sambuc "hello bar1 bar2\n"
692*11be35a1SLionel Sambuc "some more\n";
693*11be35a1SLionel Sambuc
694*11be35a1SLionel Sambuc text::templates_def templates;
695*11be35a1SLionel Sambuc templates.add_vector("table1");
696*11be35a1SLionel Sambuc templates.add_to_vector("table1", "foo1");
697*11be35a1SLionel Sambuc templates.add_to_vector("table1", "bar1");
698*11be35a1SLionel Sambuc templates.add_vector("table2");
699*11be35a1SLionel Sambuc templates.add_to_vector("table2", "foo2");
700*11be35a1SLionel Sambuc templates.add_to_vector("table2", "bar2");
701*11be35a1SLionel Sambuc
702*11be35a1SLionel Sambuc do_test_ok(templates, input, exp_output);
703*11be35a1SLionel Sambuc }
704*11be35a1SLionel Sambuc
705*11be35a1SLionel Sambuc
706*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__loop__nested__no_iterations);
ATF_TEST_CASE_BODY(instantiate__loop__nested__no_iterations)707*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__loop__nested__no_iterations)
708*11be35a1SLionel Sambuc {
709*11be35a1SLionel Sambuc const std::string input =
710*11be35a1SLionel Sambuc "first line\n"
711*11be35a1SLionel Sambuc "%loop table1 i\n"
712*11be35a1SLionel Sambuc "before: %%table1(i)%%\n"
713*11be35a1SLionel Sambuc "%loop table2 j\n"
714*11be35a1SLionel Sambuc "before: %%table2(j)%%\n"
715*11be35a1SLionel Sambuc "%loop table3 k\n"
716*11be35a1SLionel Sambuc "%%table3(k)%%\n"
717*11be35a1SLionel Sambuc "%endloop\n"
718*11be35a1SLionel Sambuc "after: %%table2(i)%%\n"
719*11be35a1SLionel Sambuc "%endloop\n"
720*11be35a1SLionel Sambuc "after: %%table1(i)%%\n"
721*11be35a1SLionel Sambuc "%endloop\n"
722*11be35a1SLionel Sambuc "some more\n";
723*11be35a1SLionel Sambuc
724*11be35a1SLionel Sambuc const std::string exp_output =
725*11be35a1SLionel Sambuc "first line\n"
726*11be35a1SLionel Sambuc "before: a\n"
727*11be35a1SLionel Sambuc "after: a\n"
728*11be35a1SLionel Sambuc "before: b\n"
729*11be35a1SLionel Sambuc "after: b\n"
730*11be35a1SLionel Sambuc "some more\n";
731*11be35a1SLionel Sambuc
732*11be35a1SLionel Sambuc text::templates_def templates;
733*11be35a1SLionel Sambuc templates.add_vector("table1");
734*11be35a1SLionel Sambuc templates.add_to_vector("table1", "a");
735*11be35a1SLionel Sambuc templates.add_to_vector("table1", "b");
736*11be35a1SLionel Sambuc templates.add_vector("table2");
737*11be35a1SLionel Sambuc templates.add_vector("table3");
738*11be35a1SLionel Sambuc templates.add_to_vector("table3", "1");
739*11be35a1SLionel Sambuc
740*11be35a1SLionel Sambuc do_test_ok(templates, input, exp_output);
741*11be35a1SLionel Sambuc }
742*11be35a1SLionel Sambuc
743*11be35a1SLionel Sambuc
744*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__loop__nested__multiple_iterations);
ATF_TEST_CASE_BODY(instantiate__loop__nested__multiple_iterations)745*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__loop__nested__multiple_iterations)
746*11be35a1SLionel Sambuc {
747*11be35a1SLionel Sambuc const std::string input =
748*11be35a1SLionel Sambuc "first line\n"
749*11be35a1SLionel Sambuc "%loop table1 i\n"
750*11be35a1SLionel Sambuc "%loop table2 j\n"
751*11be35a1SLionel Sambuc "%%table1(i)%% %%table2(j)%%\n"
752*11be35a1SLionel Sambuc "%endloop\n"
753*11be35a1SLionel Sambuc "%endloop\n"
754*11be35a1SLionel Sambuc "some more\n";
755*11be35a1SLionel Sambuc
756*11be35a1SLionel Sambuc const std::string exp_output =
757*11be35a1SLionel Sambuc "first line\n"
758*11be35a1SLionel Sambuc "a 1\n"
759*11be35a1SLionel Sambuc "a 2\n"
760*11be35a1SLionel Sambuc "a 3\n"
761*11be35a1SLionel Sambuc "b 1\n"
762*11be35a1SLionel Sambuc "b 2\n"
763*11be35a1SLionel Sambuc "b 3\n"
764*11be35a1SLionel Sambuc "some more\n";
765*11be35a1SLionel Sambuc
766*11be35a1SLionel Sambuc text::templates_def templates;
767*11be35a1SLionel Sambuc templates.add_vector("table1");
768*11be35a1SLionel Sambuc templates.add_to_vector("table1", "a");
769*11be35a1SLionel Sambuc templates.add_to_vector("table1", "b");
770*11be35a1SLionel Sambuc templates.add_vector("table2");
771*11be35a1SLionel Sambuc templates.add_to_vector("table2", "1");
772*11be35a1SLionel Sambuc templates.add_to_vector("table2", "2");
773*11be35a1SLionel Sambuc templates.add_to_vector("table2", "3");
774*11be35a1SLionel Sambuc
775*11be35a1SLionel Sambuc do_test_ok(templates, input, exp_output);
776*11be35a1SLionel Sambuc }
777*11be35a1SLionel Sambuc
778*11be35a1SLionel Sambuc
779*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__loop__sequential);
ATF_TEST_CASE_BODY(instantiate__loop__sequential)780*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__loop__sequential)
781*11be35a1SLionel Sambuc {
782*11be35a1SLionel Sambuc const std::string input =
783*11be35a1SLionel Sambuc "first line\n"
784*11be35a1SLionel Sambuc "%loop table1 iter\n"
785*11be35a1SLionel Sambuc "1: %%table1(iter)%%\n"
786*11be35a1SLionel Sambuc "%endloop\n"
787*11be35a1SLionel Sambuc "divider\n"
788*11be35a1SLionel Sambuc "%loop table2 iter\n"
789*11be35a1SLionel Sambuc "2: %%table2(iter)%%\n"
790*11be35a1SLionel Sambuc "%endloop\n"
791*11be35a1SLionel Sambuc "divider\n"
792*11be35a1SLionel Sambuc "%loop table3 iter\n"
793*11be35a1SLionel Sambuc "3: %%table3(iter)%%\n"
794*11be35a1SLionel Sambuc "%endloop\n"
795*11be35a1SLionel Sambuc "divider\n"
796*11be35a1SLionel Sambuc "%loop table4 iter\n"
797*11be35a1SLionel Sambuc "4: %%table4(iter)%%\n"
798*11be35a1SLionel Sambuc "%endloop\n"
799*11be35a1SLionel Sambuc "some more\n";
800*11be35a1SLionel Sambuc
801*11be35a1SLionel Sambuc const std::string exp_output =
802*11be35a1SLionel Sambuc "first line\n"
803*11be35a1SLionel Sambuc "1: a\n"
804*11be35a1SLionel Sambuc "1: b\n"
805*11be35a1SLionel Sambuc "divider\n"
806*11be35a1SLionel Sambuc "divider\n"
807*11be35a1SLionel Sambuc "divider\n"
808*11be35a1SLionel Sambuc "4: 1\n"
809*11be35a1SLionel Sambuc "4: 2\n"
810*11be35a1SLionel Sambuc "4: 3\n"
811*11be35a1SLionel Sambuc "some more\n";
812*11be35a1SLionel Sambuc
813*11be35a1SLionel Sambuc text::templates_def templates;
814*11be35a1SLionel Sambuc templates.add_vector("table1");
815*11be35a1SLionel Sambuc templates.add_to_vector("table1", "a");
816*11be35a1SLionel Sambuc templates.add_to_vector("table1", "b");
817*11be35a1SLionel Sambuc templates.add_vector("table2");
818*11be35a1SLionel Sambuc templates.add_vector("table3");
819*11be35a1SLionel Sambuc templates.add_vector("table4");
820*11be35a1SLionel Sambuc templates.add_to_vector("table4", "1");
821*11be35a1SLionel Sambuc templates.add_to_vector("table4", "2");
822*11be35a1SLionel Sambuc templates.add_to_vector("table4", "3");
823*11be35a1SLionel Sambuc
824*11be35a1SLionel Sambuc do_test_ok(templates, input, exp_output);
825*11be35a1SLionel Sambuc }
826*11be35a1SLionel Sambuc
827*11be35a1SLionel Sambuc
828*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__loop__scoping);
ATF_TEST_CASE_BODY(instantiate__loop__scoping)829*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__loop__scoping)
830*11be35a1SLionel Sambuc {
831*11be35a1SLionel Sambuc const std::string input =
832*11be35a1SLionel Sambuc "%loop table1 i\n"
833*11be35a1SLionel Sambuc "%if defined(i)\n" "i defined inside scope 1\n" "%endif\n"
834*11be35a1SLionel Sambuc "%loop table2 j\n"
835*11be35a1SLionel Sambuc "%if defined(i)\n" "i defined inside scope 2\n" "%endif\n"
836*11be35a1SLionel Sambuc "%if defined(j)\n" "j defined inside scope 2\n" "%endif\n"
837*11be35a1SLionel Sambuc "%endloop\n"
838*11be35a1SLionel Sambuc "%if defined(j)\n" "j defined inside scope 1\n" "%endif\n"
839*11be35a1SLionel Sambuc "%endloop\n"
840*11be35a1SLionel Sambuc "%if defined(i)\n" "i defined outside\n" "%endif\n"
841*11be35a1SLionel Sambuc "%if defined(j)\n" "j defined outside\n" "%endif\n";
842*11be35a1SLionel Sambuc
843*11be35a1SLionel Sambuc const std::string exp_output =
844*11be35a1SLionel Sambuc "i defined inside scope 1\n"
845*11be35a1SLionel Sambuc "i defined inside scope 2\n"
846*11be35a1SLionel Sambuc "j defined inside scope 2\n"
847*11be35a1SLionel Sambuc "i defined inside scope 1\n"
848*11be35a1SLionel Sambuc "i defined inside scope 2\n"
849*11be35a1SLionel Sambuc "j defined inside scope 2\n";
850*11be35a1SLionel Sambuc
851*11be35a1SLionel Sambuc text::templates_def templates;
852*11be35a1SLionel Sambuc templates.add_vector("table1");
853*11be35a1SLionel Sambuc templates.add_to_vector("table1", "first");
854*11be35a1SLionel Sambuc templates.add_to_vector("table1", "second");
855*11be35a1SLionel Sambuc templates.add_vector("table2");
856*11be35a1SLionel Sambuc templates.add_to_vector("table2", "first");
857*11be35a1SLionel Sambuc
858*11be35a1SLionel Sambuc do_test_ok(templates, input, exp_output);
859*11be35a1SLionel Sambuc }
860*11be35a1SLionel Sambuc
861*11be35a1SLionel Sambuc
862*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__mismatched_delimiters);
ATF_TEST_CASE_BODY(instantiate__mismatched_delimiters)863*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__mismatched_delimiters)
864*11be35a1SLionel Sambuc {
865*11be35a1SLionel Sambuc const std::string input =
866*11be35a1SLionel Sambuc "this is some %% text\n"
867*11be35a1SLionel Sambuc "and this is %%var%% text%%\n";
868*11be35a1SLionel Sambuc
869*11be35a1SLionel Sambuc const std::string exp_output =
870*11be35a1SLionel Sambuc "this is some %% text\n"
871*11be35a1SLionel Sambuc "and this is some more text%%\n";
872*11be35a1SLionel Sambuc
873*11be35a1SLionel Sambuc text::templates_def templates;
874*11be35a1SLionel Sambuc templates.add_variable("var", "some more");
875*11be35a1SLionel Sambuc
876*11be35a1SLionel Sambuc do_test_ok(templates, input, exp_output);
877*11be35a1SLionel Sambuc }
878*11be35a1SLionel Sambuc
879*11be35a1SLionel Sambuc
880*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__empty_statement);
ATF_TEST_CASE_BODY(instantiate__empty_statement)881*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__empty_statement)
882*11be35a1SLionel Sambuc {
883*11be35a1SLionel Sambuc do_test_fail(text::templates_def(), "%\n", "Empty statement");
884*11be35a1SLionel Sambuc }
885*11be35a1SLionel Sambuc
886*11be35a1SLionel Sambuc
887*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__unknown_statement);
ATF_TEST_CASE_BODY(instantiate__unknown_statement)888*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__unknown_statement)
889*11be35a1SLionel Sambuc {
890*11be35a1SLionel Sambuc do_test_fail(text::templates_def(), "%if2\n", "Unknown statement 'if2'");
891*11be35a1SLionel Sambuc }
892*11be35a1SLionel Sambuc
893*11be35a1SLionel Sambuc
894*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__invalid_narguments);
ATF_TEST_CASE_BODY(instantiate__invalid_narguments)895*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__invalid_narguments)
896*11be35a1SLionel Sambuc {
897*11be35a1SLionel Sambuc do_test_fail(text::templates_def(), "%if a b\n",
898*11be35a1SLionel Sambuc "Invalid number of arguments for statement 'if'");
899*11be35a1SLionel Sambuc }
900*11be35a1SLionel Sambuc
901*11be35a1SLionel Sambuc
902*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__files__ok);
ATF_TEST_CASE_BODY(instantiate__files__ok)903*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__files__ok)
904*11be35a1SLionel Sambuc {
905*11be35a1SLionel Sambuc text::templates_def templates;
906*11be35a1SLionel Sambuc templates.add_variable("string", "Hello, world!");
907*11be35a1SLionel Sambuc
908*11be35a1SLionel Sambuc atf::utils::create_file("input.txt", "The string is: %%string%%\n");
909*11be35a1SLionel Sambuc
910*11be35a1SLionel Sambuc text::instantiate(templates, fs::path("input.txt"), fs::path("output.txt"));
911*11be35a1SLionel Sambuc
912*11be35a1SLionel Sambuc std::ifstream output("output.txt");
913*11be35a1SLionel Sambuc std::string line;
914*11be35a1SLionel Sambuc ATF_REQUIRE(std::getline(output, line).good());
915*11be35a1SLionel Sambuc ATF_REQUIRE_EQ(line, "The string is: Hello, world!");
916*11be35a1SLionel Sambuc ATF_REQUIRE(std::getline(output, line).eof());
917*11be35a1SLionel Sambuc }
918*11be35a1SLionel Sambuc
919*11be35a1SLionel Sambuc
920*11be35a1SLionel Sambuc ATF_TEST_CASE_WITHOUT_HEAD(instantiate__files__input_error);
ATF_TEST_CASE_BODY(instantiate__files__input_error)921*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__files__input_error)
922*11be35a1SLionel Sambuc {
923*11be35a1SLionel Sambuc text::templates_def templates;
924*11be35a1SLionel Sambuc ATF_REQUIRE_THROW_RE(text::error, "Failed to open input.txt for read",
925*11be35a1SLionel Sambuc text::instantiate(templates, fs::path("input.txt"),
926*11be35a1SLionel Sambuc fs::path("output.txt")));
927*11be35a1SLionel Sambuc }
928*11be35a1SLionel Sambuc
929*11be35a1SLionel Sambuc
930*11be35a1SLionel Sambuc ATF_TEST_CASE(instantiate__files__output_error);
ATF_TEST_CASE_HEAD(instantiate__files__output_error)931*11be35a1SLionel Sambuc ATF_TEST_CASE_HEAD(instantiate__files__output_error)
932*11be35a1SLionel Sambuc {
933*11be35a1SLionel Sambuc set_md_var("require.user", "unprivileged");
934*11be35a1SLionel Sambuc }
ATF_TEST_CASE_BODY(instantiate__files__output_error)935*11be35a1SLionel Sambuc ATF_TEST_CASE_BODY(instantiate__files__output_error)
936*11be35a1SLionel Sambuc {
937*11be35a1SLionel Sambuc text::templates_def templates;
938*11be35a1SLionel Sambuc
939*11be35a1SLionel Sambuc atf::utils::create_file("input.txt", "");
940*11be35a1SLionel Sambuc
941*11be35a1SLionel Sambuc fs::mkdir(fs::path("dir"), 0444);
942*11be35a1SLionel Sambuc
943*11be35a1SLionel Sambuc ATF_REQUIRE_THROW_RE(text::error, "Failed to open dir/output.txt for write",
944*11be35a1SLionel Sambuc text::instantiate(templates, fs::path("input.txt"),
945*11be35a1SLionel Sambuc fs::path("dir/output.txt")));
946*11be35a1SLionel Sambuc }
947*11be35a1SLionel Sambuc
948*11be35a1SLionel Sambuc
ATF_INIT_TEST_CASES(tcs)949*11be35a1SLionel Sambuc ATF_INIT_TEST_CASES(tcs)
950*11be35a1SLionel Sambuc {
951*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__add_variable__first);
952*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__add_variable__replace);
953*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__remove_variable);
954*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__add_vector__first);
955*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__add_vector__replace);
956*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__add_to_vector);
957*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__exists__variable);
958*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__exists__vector);
959*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__get_variable__ok);
960*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__get_variable__unknown);
961*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__get_vector__ok);
962*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__get_vector__unknown);
963*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__evaluate__variable__ok);
964*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__evaluate__variable__unknown);
965*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__evaluate__vector__ok);
966*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__evaluate__vector__unknown_vector);
967*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__evaluate__vector__unknown_index);
968*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__evaluate__vector__out_of_range);
969*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__evaluate__defined);
970*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__evaluate__length__ok);
971*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__evaluate__length__unknown_vector);
972*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, templates_def__evaluate__parenthesis_error);
973*11be35a1SLionel Sambuc
974*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__empty_input);
975*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__value__ok);
976*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__value__unknown_variable);
977*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__vector_length__ok);
978*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__vector_length__unknown_vector);
979*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__vector_value__ok);
980*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__vector_value__unknown_vector);
981*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__vector_value__out_of_range__empty);
982*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__vector_value__out_of_range__not_empty);
983*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__if__one_level__taken);
984*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__if__one_level__not_taken);
985*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__if__multiple_levels__taken);
986*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__if__multiple_levels__not_taken);
987*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__loop__no_iterations);
988*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__loop__multiple_iterations);
989*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__loop__nested__no_iterations);
990*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__loop__nested__multiple_iterations);
991*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__loop__sequential);
992*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__loop__scoping);
993*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__mismatched_delimiters);
994*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__empty_statement);
995*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__unknown_statement);
996*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__invalid_narguments);
997*11be35a1SLionel Sambuc
998*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__files__ok);
999*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__files__input_error);
1000*11be35a1SLionel Sambuc ATF_ADD_TEST_CASE(tcs, instantiate__files__output_error);
1001*11be35a1SLionel Sambuc }
1002