Commit 133c8819 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by olivier stasse

Add unit tests.

parent 28e306bc
...@@ -19,6 +19,10 @@ BOOST_AUTO_TEST_CASE(value_none) { ...@@ -19,6 +19,10 @@ BOOST_AUTO_TEST_CASE(value_none) {
Value value1; Value value1;
Value value(value1); Value value(value1);
// Similar to NaN != NaN
BOOST_CHECK(!(value1 == value));
{ {
output_test_stream output; output_test_stream output;
output << value1; output << value1;
...@@ -33,6 +37,8 @@ BOOST_AUTO_TEST_CASE(value_bool) { ...@@ -33,6 +37,8 @@ BOOST_AUTO_TEST_CASE(value_bool) {
Value value1(abool1); Value value1(abool1);
Value value = value1; Value value = value1;
BOOST_CHECK(value1 == value);
{ {
output_test_stream output; output_test_stream output;
output << value1; output << value1;
...@@ -166,6 +172,8 @@ BOOST_AUTO_TEST_CASE(value_unsigned_int) { ...@@ -166,6 +172,8 @@ BOOST_AUTO_TEST_CASE(value_unsigned_int) {
Value value1(aint1); Value value1(aint1);
Value value = value1; Value value = value1;
BOOST_CHECK(value1 == value);
{ {
output_test_stream output; output_test_stream output;
output << value1; output << value1;
...@@ -186,6 +194,8 @@ BOOST_AUTO_TEST_CASE(value_int) { ...@@ -186,6 +194,8 @@ BOOST_AUTO_TEST_CASE(value_int) {
Value value1(aint1); Value value1(aint1);
Value value = value1; Value value = value1;
BOOST_CHECK(value1 == value);
{ {
output_test_stream output; output_test_stream output;
output << value1; output << value1;
...@@ -206,6 +216,8 @@ BOOST_AUTO_TEST_CASE(value_float) { ...@@ -206,6 +216,8 @@ BOOST_AUTO_TEST_CASE(value_float) {
Value value1(afloat1); Value value1(afloat1);
Value value = value1; Value value = value1;
BOOST_CHECK(value1 == value);
{ {
output_test_stream output; output_test_stream output;
output << value1; output << value1;
...@@ -226,6 +238,8 @@ BOOST_AUTO_TEST_CASE(value_double) { ...@@ -226,6 +238,8 @@ BOOST_AUTO_TEST_CASE(value_double) {
Value value1(adouble1); Value value1(adouble1);
Value value = value1; Value value = value1;
BOOST_CHECK(value1 == value);
{ {
output_test_stream output; output_test_stream output;
output << value1; output << value1;
...@@ -249,6 +263,8 @@ BOOST_AUTO_TEST_CASE(value_vector) { ...@@ -249,6 +263,8 @@ BOOST_AUTO_TEST_CASE(value_vector) {
Value value1(avector1); Value value1(avector1);
Value value = value1; Value value = value1;
BOOST_CHECK(value1 == value);
{ {
output_test_stream output; output_test_stream output;
output << value1; output << value1;
...@@ -269,6 +285,8 @@ BOOST_AUTO_TEST_CASE(value_string) { ...@@ -269,6 +285,8 @@ BOOST_AUTO_TEST_CASE(value_string) {
Value value1(str1); Value value1(str1);
Value value = value1; Value value = value1;
BOOST_CHECK(value1 == value);
{ {
output_test_stream output; output_test_stream output;
output << value1; output << value1;
...@@ -310,6 +328,8 @@ BOOST_AUTO_TEST_CASE(value_matrixXd) { ...@@ -310,6 +328,8 @@ BOOST_AUTO_TEST_CASE(value_matrixXd) {
Value value1(avector1); Value value1(avector1);
Value value = value1; Value value = value1;
BOOST_CHECK(value1 == value);
{ {
output_test_stream output; output_test_stream output;
output << value1; output << value1;
...@@ -335,6 +355,8 @@ BOOST_AUTO_TEST_CASE(value_matrix4d) { ...@@ -335,6 +355,8 @@ BOOST_AUTO_TEST_CASE(value_matrix4d) {
Value value1(avector1); Value value1(avector1);
Value value = value1; Value value = value1;
BOOST_CHECK(value1 == value);
{ {
output_test_stream output; output_test_stream output;
output << value1; output << value1;
...@@ -369,7 +391,28 @@ BOOST_AUTO_TEST_CASE(value_values) { ...@@ -369,7 +391,28 @@ BOOST_AUTO_TEST_CASE(value_values) {
BOOST_CHECK_EQUAL(vvalues.type(), Value::VALUES); BOOST_CHECK_EQUAL(vvalues.type(), Value::VALUES);
const Values& vs = vvalues.constValuesValue(); { // Const ref
BOOST_CHECK_EQUAL(vs.size(), values.size()); const Values& vs = vvalues.constValuesValue();
BOOST_CHECK(vs == values); BOOST_CHECK_EQUAL(vs.size(), values.size());
BOOST_CHECK(vs == values);
}
{ // Cast does not work.
//dg::command::EitherType eitherType (vvalues);
//Values vs = static_cast<Values>(eitherType);
//BOOST_CHECK_EQUAL(vs.size(), values.size());
//BOOST_CHECK(vs == values);
}
{ // Constructor
Value vvs (vvalues);
BOOST_CHECK(vvs == vvalues);
}
{
output_test_stream output;
output << vvalues;
BOOST_CHECK(output.is_equal("Type=values, value=[ "
"Value(Type=string, value=value #1), "
"Value(Type=double, value=0.3), "
"]"));
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment