15 #define GETTEXT_DOMAIN "wesnoth-test"
17 #include <boost/test/unit_test.hpp>
37 BOOST_CHECK_EQUAL(x_str,
"1");
38 x_int = c[
"x"].to_int();
39 BOOST_CHECK_EQUAL(x_int, 1);
40 x_sll = c[
"x"].to_long_long();
41 BOOST_CHECK_EQUAL(x_sll, 1ll);
42 x_dbl = c[
"x"].to_double();
43 BOOST_CHECK_EQUAL(x_dbl, 1.0);
47 x_int = c[
"x"].to_int();
48 BOOST_CHECK_EQUAL(x_int, 10000000);
50 BOOST_CHECK_EQUAL(x_str,
"10000000");
51 x_sll = c[
"x"].to_long_long();
52 BOOST_CHECK_EQUAL(x_sll, 10000000ll);
53 x_dbl = c[
"x"].to_double();
54 BOOST_CHECK_EQUAL(x_dbl, 1e7);
57 x_sll = c[
"x"].to_long_long();
58 BOOST_CHECK_EQUAL(x_sll, 0ll);
60 BOOST_CHECK_EQUAL(x_str,
"");
61 x_int = c[
"x"].to_int();
62 BOOST_CHECK_EQUAL(x_int, 0);
63 x_dbl = c[
"x"].to_double();
64 BOOST_CHECK_EQUAL(x_dbl, 0.0);
68 x_int = c[
"x"].to_int();
69 BOOST_CHECK_EQUAL(x_int, 0);
71 BOOST_CHECK_EQUAL(x_str,
"0x11");
72 x_sll = c[
"x"].to_long_long();
73 BOOST_CHECK_EQUAL(x_sll, 0ll);
74 x_dbl = c[
"x"].to_double();
75 BOOST_CHECK_EQUAL(x_dbl, 0.0);
79 x_int = c[
"x"].to_int();
80 BOOST_CHECK_EQUAL(x_int, 0);
82 BOOST_CHECK_EQUAL(x_str,
"0xab");
83 x_sll = c[
"x"].to_long_long();
84 BOOST_CHECK_EQUAL(x_sll, 0ll);
85 x_dbl = c[
"x"].to_double();
86 BOOST_CHECK_EQUAL(x_dbl, 0.0);
90 x_int = c[
"x"].to_int();
91 BOOST_CHECK_EQUAL(x_int, 1111);
93 BOOST_CHECK_EQUAL(x_str,
"00001111");
94 x_sll = c[
"x"].to_long_long();
95 BOOST_CHECK_EQUAL(x_sll, 1111ll);
96 x_dbl = c[
"x"].to_double();
97 BOOST_CHECK_EQUAL(x_dbl, 1.111e3);
101 x_int = c[
"x"].to_int();
102 BOOST_CHECK_EQUAL(x_int, 0);
103 x_str = c[
"x"].str();
104 BOOST_CHECK_EQUAL(x_str,
"000000");
105 x_sll = c[
"x"].to_long_long();
106 BOOST_CHECK_EQUAL(x_sll, 0ll);
107 x_dbl = c[
"x"].to_double();
108 BOOST_CHECK_EQUAL(x_dbl, 0.0);
111 c[
"x"] =
"01234567890123456789";
112 x_sll = c[
"x"].to_long_long();
113 BOOST_CHECK_EQUAL(x_sll,1234567890123456789ll);
114 x_str = c[
"x"].str();
115 BOOST_CHECK_EQUAL(x_str,
"01234567890123456789");
116 x_int = c[
"x"].to_int();
117 BOOST_CHECK_EQUAL(x_int, 0);
118 x_dbl = c[
"x"].to_double();
119 BOOST_CHECK_EQUAL(x_dbl, 1.23456789012345678e18);
122 c[
"x"] =
"99999999999999999999";
123 x_sll = c[
"x"].to_long_long();
124 BOOST_CHECK_EQUAL(x_sll, 0ll);
125 x_str = c[
"x"].str();
126 BOOST_CHECK_EQUAL(x_str,
"99999999999999999999");
127 x_int = c[
"x"].to_int();
128 BOOST_CHECK_EQUAL(x_int, 0);
129 x_dbl = c[
"x"].to_double();
130 BOOST_CHECK_EQUAL(x_dbl, 1e20);
133 x_sll = c[
"x"].to_long_long();
134 BOOST_CHECK_EQUAL(x_sll, 1ll);
135 x_str = c[
"x"].str();
136 BOOST_CHECK_EQUAL(x_str,
"1.499");
137 x_int = c[
"x"].to_int();
138 BOOST_CHECK_EQUAL(x_int, 1);
139 x_dbl = c[
"x"].to_double();
140 BOOST_CHECK(std::abs(x_dbl - 1.499) < 1
e-6);
143 c[
"x"] = 123456789123ll;
144 x_int = c[
"x"].to_int();
145 BOOST_CHECK_EQUAL(x_int, -1097262461);
146 x_dbl = c[
"x"].to_double();
147 BOOST_CHECK_EQUAL(x_dbl, 1.23456789123e11);
148 x_sll = c[
"x"].to_long_long();
149 BOOST_CHECK_EQUAL(x_sll, 123456789123ll);
150 x_str = c[
"x"].str();
151 BOOST_CHECK_EQUAL(x_str,
"123456789123");
155 BOOST_CHECK(cc[
"x"] !=
"");
156 BOOST_CHECK(cc[
"x"].empty());
157 BOOST_CHECK(cc[
"x"].blank());
159 BOOST_CHECK(c[
"x"] !=
"");
160 BOOST_CHECK(c[
"x"].empty());
161 BOOST_CHECK(c[
"x"].blank());
163 BOOST_CHECK_EQUAL(cc[
"x"], c[
"x"]);
166 BOOST_CHECK(cc[
"x"] ==
"");
167 BOOST_CHECK(cc[
"x"].empty());
168 BOOST_CHECK(!cc[
"x"].blank());
170 BOOST_CHECK(c[
"x"] ==
"");
171 BOOST_CHECK(c[
"x"].empty());
172 BOOST_CHECK(!c[
"x"].blank());
174 BOOST_CHECK_EQUAL(cc[
"x"], c[
"x"]);
211 BOOST_CHECK (c.
empty());
237 (
"atribute2",
"value")
260 BOOST_CHECK_EQUAL (
variable_access_const(
"tag1[1].tag2[2].atribute1", nonempty).as_scalar().to_int(), 88);
268 BOOST_CHECK_EQUAL (count, 3);
276 BOOST_CHECK_EQUAL (count, 0);
285 BOOST_CHECK_EQUAL (count, 1);
289 BOOST_AUTO_TEST_SUITE_END()
variable_info_detail::maybe_const< vit, config::attribute_value >::type & as_scalar() const
might throw invalid_variablename_exception NOTE: If vit == vit_const, then the lifime of the returned...
bool exists_as_container() const
might throw invalid_variablename_exception
BOOST_AUTO_TEST_CASE(test_config_attribute_value)
variable_info< variable_info_detail::vit_const > variable_access_const
this variable accessor is takes a const reference and is guaranteed to not change the config...
Extends variable_info with methods that can only be applied if vit != vit_const.
BOOST_AUTO_TEST_SUITE(test_map_location)
Definitions for the interface to Wesnoth Markup Language (WML).
Variant for storing WML attributes.
GLuint GLuint GLsizei count
GLuint GLint GLboolean GLint GLenum access
variable_info_detail::maybe_const< vit, config >::type & as_container() const
might throw invalid_variablename_exception
Information on a WML variable.
bool exists_as_attribute() const
might throw invalid_variablename_exception
A config object defines a single node in a WML file, with access to child nodes.
GLsizei const GLcharARB ** string