10 #define BOOST_TEST_MODULE value 12 #include <boost/version.hpp> 14 #if BOOST_VERSION >= 105900 15 #include <boost/test/tools/output_test_stream.hpp> 17 #include <boost/test/output_test_stream.hpp> 19 #include <boost/test/unit_test.hpp> 21 using boost::test_tools::output_test_stream;
26 using dg::command::Value;
32 BOOST_CHECK(!(value1 == value));
35 output_test_stream output;
37 BOOST_CHECK(output.is_equal(
"Type=unknown, value="));
42 using dg::command::Value;
48 BOOST_CHECK(value1 == value);
51 output_test_stream output;
53 BOOST_CHECK(output.is_equal(
"Type=bool, value=0"));
57 output_test_stream output;
59 BOOST_CHECK(output.is_equal(
"Type=bool, value=0"));
64 using dg::command::Value;
67 dg::command::EitherType anet(value1);
68 output_test_stream output, output2;
79 output2 << aea.
what();
83 BOOST_CHECK(output.is_equal(
"Abstract"));
84 BOOST_CHECK(output2.is_equal(
"value is not an int"));
102 unsigned int aint(anet);
114 double adouble(anet);
138 std::string astring(anet);
159 Eigen::MatrixXd amatrixXd;
170 Eigen::Matrix4d amatrix4d;
179 using dg::command::Value;
181 unsigned int aint1(5);
183 Value value = value1;
185 BOOST_CHECK(value1 == value);
188 output_test_stream output;
190 BOOST_CHECK(output.is_equal(
"Type=unsigned int, value=5"));
194 output_test_stream output;
196 BOOST_CHECK(output.is_equal(
"Type=unsigned int, value=5"));
201 using dg::command::Value;
205 Value value = value1;
207 BOOST_CHECK(value1 == value);
210 output_test_stream output;
212 BOOST_CHECK(output.is_equal(
"Type=int, value=5"));
216 output_test_stream output;
218 BOOST_CHECK(output.is_equal(
"Type=int, value=5"));
223 using dg::command::Value;
226 Value value1(afloat1);
227 Value value = value1;
229 BOOST_CHECK(value1 == value);
232 output_test_stream output;
234 BOOST_CHECK(output.is_equal(
"Type=float, value=0.5"));
238 output_test_stream output;
240 BOOST_CHECK(output.is_equal(
"Type=float, value=0.5"));
245 using dg::command::Value;
247 double adouble1(0.5);
248 Value value1(adouble1);
249 Value value = value1;
251 BOOST_CHECK(value1 == value);
254 output_test_stream output;
256 BOOST_CHECK(output.is_equal(
"Type=double, value=0.5"));
260 output_test_stream output;
262 BOOST_CHECK(output.is_equal(
"Type=double, value=0.5"));
267 using dg::command::Value;
273 Value value1(avector1);
274 Value value = value1;
276 BOOST_CHECK(value1 == value);
279 output_test_stream output;
281 BOOST_CHECK(output.is_equal(
"Type=vector, value=0.5\n1.5"));
285 output_test_stream output;
287 BOOST_CHECK(output.is_equal(
"Type=vector, value=0.5\n1.5"));
292 using dg::command::Value;
294 std::string str1(
"value #1");
296 Value value = value1;
298 BOOST_CHECK(value1 == value);
301 output_test_stream output;
303 BOOST_CHECK(output.is_equal(
"Type=string, value=value #1"));
307 output_test_stream output;
309 BOOST_CHECK(output.is_equal(
"Type=string, value=value #1"));
312 std::string str2(
"value #2");
317 output_test_stream output;
319 BOOST_CHECK(output.is_equal(
"Type=string, value=value #2"));
323 output_test_stream output;
325 BOOST_CHECK(output.is_equal(
"Type=string, value=value #2"));
330 using dg::command::Value;
332 Eigen::MatrixXd avector1;
333 avector1.resize(2, 2);
334 avector1(0, 0) = 0.5;
335 avector1(0, 1) = 1.5;
336 avector1(1, 0) = 2.5;
337 avector1(1, 1) = 3.5;
338 Value value1(avector1);
339 Value value = value1;
341 BOOST_CHECK(value1 == value);
344 output_test_stream output;
346 BOOST_CHECK(output.is_equal(
"Type=matrixXd, value=0.5 1.5\n2.5 3.5"));
350 output_test_stream output;
352 BOOST_CHECK(output.is_equal(
"Type=matrixXd, value=0.5 1.5\n2.5 3.5"));
357 using dg::command::Value;
359 Eigen::Matrix4d avector1;
361 avector1(0, 0) = 0.5;
362 avector1(0, 1) = 1.5;
363 avector1(1, 0) = 2.5;
364 avector1(1, 1) = 3.5;
365 Value value1(avector1);
366 Value value = value1;
368 BOOST_CHECK(value1 == value);
371 output_test_stream output;
374 output.is_equal(
"Type=matrix4d, value=0.5 1.5 0 0\n" 375 "2.5 3.5 0 0\n 0 0 0 0\n" 380 output_test_stream output;
383 output.is_equal(
"Type=matrix4d, value=0.5 1.5 0 0\n" 384 "2.5 3.5 0 0\n 0 0 0 0\n" 392 std::string s1(
"value #1");
399 values.push_back(vs1);
400 values.push_back(vd1);
402 Value vvalues(values);
407 const Values &vs = vvalues.constValuesValue();
408 BOOST_CHECK_EQUAL(vs.size(), values.size());
409 BOOST_CHECK(vs == values);
419 BOOST_CHECK(vvs == vvalues);
423 output_test_stream output;
426 output.is_equal(
"Type=values, value=[ " 427 "Value(Type=string, value=value #1), " 428 "Value(Type=double, value=0.3), "
int getCode() const
Access to the error code.
virtual const std::string & getExceptionName() const
Abstract root class for all dynamic-graph exceptions.
BOOST_AUTO_TEST_CASE(value_none)
virtual const char * what() const
std::vector< Value > Values