16 #define GETTEXT_DOMAIN "wesnoth-test"
18 #include <boost/test/unit_test.hpp>
32 formula(
"substring('hello world', 0)")
33 .evaluate().as_string()
37 formula(
"substring('hello world', 6)")
38 .evaluate().as_string()
44 formula(
"substring('hello world', 11)")
45 .evaluate().as_string()
51 formula(
"substring('hello world', -1)")
52 .evaluate().as_string()
56 formula(
"substring('hello world', -5)")
57 .evaluate().as_string()
61 formula(
"substring('hello world', -11)")
62 .evaluate().as_string()
68 formula(
"substring('hello world', -12)")
69 .evaluate().as_string()
75 formula(
"substring('hello world', 0, 0)")
76 .evaluate().as_string()
80 formula(
"substring('hello world', 0, -1)")
81 .evaluate().as_string()
87 formula(
"substring('hello world', 5, 1)")
88 .evaluate().as_string()
92 formula(
"substring('hello world', 1, 9)")
93 .evaluate().as_string()
97 formula(
"substring('hello world', -10, 9)")
98 .evaluate().as_string()
102 formula(
"substring('hello world', -1, -5)")
103 .evaluate().as_string()
107 formula(
"substring('hello world', 4, -5)")
108 .evaluate().as_string()
117 formula(
"length('')").evaluate().as_int()
121 formula(
"length('hello world')").evaluate().as_int()
128 formula(
"concatenate(100)").evaluate().as_string()
132 formula(
"concatenate(100, 200, 'a')")
133 .evaluate().as_string()
137 formula(
"concatenate([1,2,3])")
138 .evaluate().as_string()
143 "concatenate([1.0, 1.00, 1.000, 1.2, 1.23, 1.234])")
144 .evaluate().as_string()
145 ,
"1.000, 1.000, 1.000, 1.200, 1.230, 1.234");
150 BOOST_CHECK_EQUAL(
formula(
"abs(5)").evaluate().as_int(), 5);
151 BOOST_CHECK_EQUAL(
formula(
"abs(-5)").evaluate().as_int(), 5);
152 BOOST_CHECK_EQUAL(
formula(
"abs(5.0)").evaluate().as_int(), 5);
153 BOOST_CHECK_EQUAL(
formula(
"abs(-5.0)").evaluate().as_int(), 5);
155 BOOST_CHECK_EQUAL(
formula(
"min(3,5)").evaluate().as_int(), 3);
156 BOOST_CHECK_EQUAL(
formula(
"min(5,2)").evaluate().as_int(), 2);
157 BOOST_CHECK_EQUAL(
formula(
"max(3,5)").evaluate().as_int(), 5);
158 BOOST_CHECK_EQUAL(
formula(
"max(5,2)").evaluate().as_int(), 5);
159 BOOST_CHECK_EQUAL(
formula(
"max(5.5,5)").evaluate().as_decimal(),
160 static_cast<int>(1000.0 * 5.5));
162 BOOST_CHECK_EQUAL(
formula(
"max(4,5,[2,18,7])").evaluate().as_int(), 18);
164 BOOST_CHECK_EQUAL(
formula(
"log(8,2)").evaluate().as_int(), 3);
165 BOOST_CHECK_EQUAL(
formula(
"log(12)").evaluate().as_decimal(),
166 static_cast<int>(round(1000.0 * std::log(12))));
167 BOOST_CHECK_EQUAL(
formula(
"exp(3)").evaluate().as_decimal(),
168 static_cast<int>(round(1000.0 * std::exp(3))));
173 const double pi = 4. * std::atan(1.);
177 for(std::size_t x = 0; x <= 360; ++x) {
182 .evaluate(variables).as_decimal()
183 ,
static_cast<int>(round(1000. * std::sin(x * pi / 180.))));
187 .evaluate(variables).as_decimal()
188 ,
static_cast<int>(round(1000. * std::cos(x * pi / 180.))));
190 if(x % 90 == 0 && x % 180 != 0) {
193 .evaluate(variables).is_null());
197 .evaluate(variables).as_decimal(),
198 static_cast<int>(round(1000. * std::tan(x * pi / 180.))));
203 BOOST_AUTO_TEST_SUITE_END()
Standard logging facilities (interface).
bool set_log_domain_severity(const std::string &name, severity severity)
BOOST_AUTO_TEST_SUITE(filesystem)