From 133c88191427ae0393e3d274646b62ffd3ac48a7 Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Mon, 27 Jan 2020 16:57:18 +0100
Subject: [PATCH] Add unit tests.

---
 tests/value.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 46 insertions(+), 3 deletions(-)

diff --git a/tests/value.cpp b/tests/value.cpp
index af32117..2c86986 100644
--- a/tests/value.cpp
+++ b/tests/value.cpp
@@ -19,6 +19,10 @@ BOOST_AUTO_TEST_CASE(value_none) {
 
   Value value1;
   Value value(value1);
+
+  // Similar to NaN != NaN
+  BOOST_CHECK(!(value1 == value));
+
   {
     output_test_stream output;
     output << value1;
@@ -33,6 +37,8 @@ BOOST_AUTO_TEST_CASE(value_bool) {
   Value value1(abool1);
   Value value = value1;
 
+  BOOST_CHECK(value1 == value);
+
   {
     output_test_stream output;
     output << value1;
@@ -166,6 +172,8 @@ BOOST_AUTO_TEST_CASE(value_unsigned_int) {
   Value value1(aint1);
   Value value = value1;
 
+  BOOST_CHECK(value1 == value);
+
   {
     output_test_stream output;
     output << value1;
@@ -186,6 +194,8 @@ BOOST_AUTO_TEST_CASE(value_int) {
   Value value1(aint1);
   Value value = value1;
 
+  BOOST_CHECK(value1 == value);
+
   {
     output_test_stream output;
     output << value1;
@@ -206,6 +216,8 @@ BOOST_AUTO_TEST_CASE(value_float) {
   Value value1(afloat1);
   Value value = value1;
 
+  BOOST_CHECK(value1 == value);
+
   {
     output_test_stream output;
     output << value1;
@@ -226,6 +238,8 @@ BOOST_AUTO_TEST_CASE(value_double) {
   Value value1(adouble1);
   Value value = value1;
 
+  BOOST_CHECK(value1 == value);
+
   {
     output_test_stream output;
     output << value1;
@@ -249,6 +263,8 @@ BOOST_AUTO_TEST_CASE(value_vector) {
   Value value1(avector1);
   Value value = value1;
 
+  BOOST_CHECK(value1 == value);
+
   {
     output_test_stream output;
     output << value1;
@@ -269,6 +285,8 @@ BOOST_AUTO_TEST_CASE(value_string) {
   Value value1(str1);
   Value value = value1;
 
+  BOOST_CHECK(value1 == value);
+
   {
     output_test_stream output;
     output << value1;
@@ -310,6 +328,8 @@ BOOST_AUTO_TEST_CASE(value_matrixXd) {
   Value value1(avector1);
   Value value = value1;
 
+  BOOST_CHECK(value1 == value);
+
   {
     output_test_stream output;
     output << value1;
@@ -335,6 +355,8 @@ BOOST_AUTO_TEST_CASE(value_matrix4d) {
   Value value1(avector1);
   Value value = value1;
 
+  BOOST_CHECK(value1 == value);
+
   {
     output_test_stream output;
     output << value1;
@@ -369,7 +391,28 @@ BOOST_AUTO_TEST_CASE(value_values) {
 
   BOOST_CHECK_EQUAL(vvalues.type(), Value::VALUES);
 
-  const Values& vs = vvalues.constValuesValue();
-  BOOST_CHECK_EQUAL(vs.size(), values.size());
-  BOOST_CHECK(vs == values);
+  { // Const ref
+    const Values& vs = vvalues.constValuesValue();
+    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), "
+                                "]"));
+  }
 }
-- 
GitLab