16 #define GETTEXT_DOMAIN "wesnoth-test"
18 #include <boost/test/unit_test.hpp>
21 #include <boost/test/data/test_case.hpp>
43 BOOST_CHECK_EQUAL(c1[
"x"], c2[
"x"]);
48 BOOST_CHECK_EQUAL(c1[
"x"], c2[
"x"]);
53 BOOST_CHECK_EQUAL(c1[
"x"], c2[
"x"]);
58 BOOST_CHECK_NE(c1[
"x"], c2[
"x"]);
63 BOOST_CHECK_NE(c1[
"x"], c2[
"x"]);
68 BOOST_CHECK_EQUAL(x_str,
"1aaaa");
69 x_int =
c[
"x"].to_int();
70 BOOST_CHECK_EQUAL(x_int, 1);
71 x_sll =
c[
"x"].to_long_long();
72 BOOST_CHECK_EQUAL(x_sll, 1ll);
73 x_dbl =
c[
"x"].to_double();
74 BOOST_CHECK_EQUAL(x_dbl, 1.0);
78 BOOST_CHECK_EQUAL(x_str,
"1.7aaaa");
79 x_int =
c[
"x"].to_int();
80 BOOST_CHECK_EQUAL(x_int, 1);
81 x_sll =
c[
"x"].to_long_long();
82 BOOST_CHECK_EQUAL(x_sll, 1ll);
83 x_dbl =
c[
"x"].to_double();
84 BOOST_CHECK_EQUAL(x_dbl, 1.7);
88 BOOST_CHECK_EQUAL(x_str,
"aaaa1");
89 x_int =
c[
"x"].to_int();
90 BOOST_CHECK_EQUAL(x_int, 0);
91 x_sll =
c[
"x"].to_long_long();
92 BOOST_CHECK_EQUAL(x_sll, 0ll);
93 x_dbl =
c[
"x"].to_double();
94 BOOST_CHECK_EQUAL(x_dbl, 0.0);
99 BOOST_CHECK_EQUAL(x_str,
"1");
100 x_int =
c[
"x"].to_int();
101 BOOST_CHECK_EQUAL(x_int, 1);
102 x_sll =
c[
"x"].to_long_long();
103 BOOST_CHECK_EQUAL(x_sll, 1ll);
104 x_dbl =
c[
"x"].to_double();
105 BOOST_CHECK_EQUAL(x_dbl, 1.0);
109 x_int =
c[
"x"].to_int();
110 BOOST_CHECK_EQUAL(x_int, 10000000);
111 x_str =
c[
"x"].str();
112 BOOST_CHECK_EQUAL(x_str,
"10000000");
113 x_sll =
c[
"x"].to_long_long();
114 BOOST_CHECK_EQUAL(x_sll, 10000000ll);
115 x_dbl =
c[
"x"].to_double();
116 BOOST_CHECK_EQUAL(x_dbl, 1e7);
120 x_sll =
c[
"x"].to_long_long();
121 BOOST_CHECK_EQUAL(x_sll, 0ll);
122 x_str =
c[
"x"].str();
123 BOOST_CHECK_EQUAL(x_str,
"");
124 x_int =
c[
"x"].to_int();
125 BOOST_CHECK_EQUAL(x_int, 0);
126 x_dbl =
c[
"x"].to_double();
127 BOOST_CHECK_EQUAL(x_dbl, 0.0);
131 x_int =
c[
"x"].to_int();
132 BOOST_CHECK_EQUAL(x_int, 0);
133 x_str =
c[
"x"].str();
134 BOOST_CHECK_EQUAL(x_str,
"0x11");
135 x_sll =
c[
"x"].to_long_long();
136 BOOST_CHECK_EQUAL(x_sll, 0ll);
137 x_dbl =
c[
"x"].to_double();
138 BOOST_CHECK_EQUAL(x_dbl, 0.0);
142 x_int =
c[
"x"].to_int();
143 BOOST_CHECK_EQUAL(x_int, 0);
144 x_str =
c[
"x"].str();
145 BOOST_CHECK_EQUAL(x_str,
"0xab");
146 x_sll =
c[
"x"].to_long_long();
147 BOOST_CHECK_EQUAL(x_sll, 0ll);
148 x_dbl =
c[
"x"].to_double();
149 BOOST_CHECK_EQUAL(x_dbl, 0.0);
153 x_int =
c[
"x"].to_int();
154 BOOST_CHECK_EQUAL(x_int, 1111);
155 x_str =
c[
"x"].str();
156 BOOST_CHECK_EQUAL(x_str,
"00001111");
157 x_sll =
c[
"x"].to_long_long();
158 BOOST_CHECK_EQUAL(x_sll, 1111ll);
159 x_dbl =
c[
"x"].to_double();
160 BOOST_CHECK_EQUAL(x_dbl, 1.111e3);
164 x_int =
c[
"x"].to_int();
165 BOOST_CHECK_EQUAL(x_int, 0);
166 x_str =
c[
"x"].str();
167 BOOST_CHECK_EQUAL(x_str,
"000000");
168 x_sll =
c[
"x"].to_long_long();
169 BOOST_CHECK_EQUAL(x_sll, 0ll);
170 x_dbl =
c[
"x"].to_double();
171 BOOST_CHECK_EQUAL(x_dbl, 0.0);
174 c[
"x"] =
"01234567890123456789";
175 x_sll =
c[
"x"].to_long_long();
176 BOOST_CHECK_EQUAL(x_sll, 1234567890123456789ll);
177 x_str =
c[
"x"].str();
178 BOOST_CHECK_EQUAL(x_str,
"01234567890123456789");
179 x_int =
c[
"x"].to_int();
180 BOOST_CHECK_EQUAL(x_int, 0);
181 x_dbl =
c[
"x"].to_double();
182 BOOST_CHECK_EQUAL(x_dbl, 1.23456789012345678e18);
185 c[
"x"] =
"99999999999999999999";
186 x_sll =
c[
"x"].to_long_long();
187 BOOST_CHECK_EQUAL(x_sll, 0ll);
188 x_str =
c[
"x"].str();
189 BOOST_CHECK_EQUAL(x_str,
"99999999999999999999");
190 x_int =
c[
"x"].to_int();
191 BOOST_CHECK_EQUAL(x_int, 0);
192 x_dbl =
c[
"x"].to_double();
193 BOOST_CHECK_EQUAL(x_dbl, 1e20);
197 x_sll =
c[
"x"].to_long_long();
198 BOOST_CHECK_EQUAL(x_sll, 1ll);
199 x_str =
c[
"x"].str();
200 BOOST_CHECK_EQUAL(x_str,
"1.499");
201 x_int =
c[
"x"].to_int();
202 BOOST_CHECK_EQUAL(x_int, 1);
203 x_dbl =
c[
"x"].to_double();
204 BOOST_CHECK(std::abs(x_dbl - 1.499) < 1
e-6);
207 c[
"x"] = 123456789123ll;
208 x_int =
c[
"x"].to_int();
209 BOOST_CHECK_EQUAL(x_int, -1097262461);
210 x_dbl =
c[
"x"].to_double();
211 BOOST_CHECK_EQUAL(x_dbl, 1.23456789123e11);
212 x_sll =
c[
"x"].to_long_long();
213 BOOST_CHECK_EQUAL(x_sll, 123456789123ll);
214 x_str =
c[
"x"].str();
215 BOOST_CHECK_EQUAL(x_str,
"123456789123");
219 BOOST_CHECK_EQUAL(
c[
"x"], 987654321);
221 BOOST_CHECK_EQUAL(
c[
"x"],
"1");
223 BOOST_CHECK_EQUAL(
c[
"x"],
"222");
225 BOOST_CHECK_EQUAL(
c[
"x"],
"test");
227 BOOST_CHECK_EQUAL(
c[
"x"], 33333);
229 BOOST_CHECK_EQUAL(
c[
"x"],
true);
231 BOOST_CHECK_EQUAL(
c[
"x"],
"no");
233 BOOST_CHECK_EQUAL(
c[
"x"], 1.23456789);
235 c[
"x"] =
"9.87654321";
236 BOOST_CHECK_EQUAL(
c[
"x"], 9.87654321);
238 c[
"x"] =
"sfvsdgdsfg";
239 BOOST_CHECK_NE(
c[
"x"], 0);
240 BOOST_CHECK_NE(
c[
"x"],
true);
241 BOOST_CHECK_NE(
c[
"x"],
"a random string");
245 BOOST_CHECK(cc[
"x"] !=
"");
246 BOOST_CHECK(cc[
"x"].empty());
247 BOOST_CHECK(cc[
"x"].
blank());
249 BOOST_CHECK(
c[
"x"] !=
"");
250 BOOST_CHECK(
c[
"x"].empty());
251 BOOST_CHECK(
c[
"x"].
blank());
253 BOOST_CHECK_EQUAL(cc[
"x"],
c[
"x"]);
256 BOOST_CHECK(cc[
"x"].empty());
257 BOOST_CHECK(cc[
"x"].empty());
258 BOOST_CHECK(!cc[
"x"].
blank());
260 BOOST_CHECK(
c[
"x"].empty());
261 BOOST_CHECK(
c[
"x"].empty());
262 BOOST_CHECK(!
c[
"x"].
blank());
264 BOOST_CHECK_EQUAL(cc[
"x"],
c[
"x"]);
301 BOOST_CHECK(
c.empty());
328 "atribute2",
"value",
353 BOOST_CHECK_EQUAL(
variable_access_const(
"tag1[1].tag2[2].atribute1", nonempty).as_scalar().to_int(), 88);
358 BOOST_CHECK_EQUAL(count, 3);
363 BOOST_CHECK_EQUAL(count, 0);
369 BOOST_CHECK_EQUAL(count, 1);
377 const config expected(
"A");
378 BOOST_CHECK_EQUAL(actual, expected);
379 BOOST_CHECK_EQUAL(new_child,
config());
384 bdata::make({
"A",
"B",
"C"}) * bdata::make<std::string>({
"lvalue_ref",
"rvalue_ref"}),
402 if(update_ref_kind == std::string(
"lvalue_ref"))
407 BOOST_CHECK_EQUAL(actual, expected);
408 BOOST_CHECK_EQUAL(new_child,
update);
410 BOOST_CHECK_NE(&new_child, &
update);
413 BOOST_AUTO_TEST_SUITE_END()
Variant for storing WML attributes.
A config object defines a single node in a WML file, with access to child nodes.
config & add_child(config_key_type key)
Additional functionality for a non-const variable_info.
Information on a WML variable.
maybe_const_t< config::attribute_value, V > & as_scalar() const
If instantiated with vi_policy_const, the lifetime of the returned const attribute_value reference mi...
bool exists_as_container() const
maybe_const_t< config, V > & as_container() const
If instantiated with vi_policy_const, the lifetime of the returned const attribute_value reference mi...
bool exists_as_attribute() const
Definitions for the interface to Wesnoth Markup Language (WML).
BOOST_AUTO_TEST_CASE(test_config_attribute_value)
BOOST_DATA_TEST_CASE(add_child_NonEmptyThis_newOrExistingKey_lOrRValue_AppendAndReturnNewChild, bdata::make({"A", "B", "C"}) *bdata::make< std::string >({"lvalue_ref", "rvalue_ref"}), key, update_ref_kind)
BOOST_AUTO_TEST_SUITE(filesystem)
variable_info< const variable_info_implementation::vi_policy_const > variable_access_const
Read-only access.