Add datastore support for bits

Change-Id: I9a1619f6b892bbde71e75376e9a3a84911236b5d
diff --git a/tests/datastore_access.cpp b/tests/datastore_access.cpp
index da3bc48..022b115 100644
--- a/tests/datastore_access.cpp
+++ b/tests/datastore_access.cpp
@@ -508,6 +508,17 @@
         REQUIRE(datastore.getItems("/example-schema:dummy") == expected);
     }
 
+    SECTION("bits")
+    {
+        datastore.setLeaf("/example-schema:flags", bits_{{"sign", "carry"}});
+        REQUIRE_CALL(mock, write("/example-schema:flags", std::nullopt, "carry sign"s));
+        datastore.commitChanges();
+        DatastoreAccess::Tree expected {
+            {"/example-schema:flags", bits_{{"carry", "sign"}}},
+        };
+        REQUIRE(datastore.getItems("/example-schema:flags") == expected);
+    }
+
 #if not defined(yang_BACKEND)
     SECTION("operational data")
     {
diff --git a/tests/example-schema.yang b/tests/example-schema.yang
index da45afd..372b83d 100644
--- a/tests/example-schema.yang
+++ b/tests/example-schema.yang
@@ -294,4 +294,13 @@
             type int32;
         }
     }
+
+    leaf flags {
+        type bits {
+            bit carry;
+            bit zero;
+            bit sign;
+            bit parity;
+        }
+    }
 }
diff --git a/tests/mock/sysrepo_subscription.cpp b/tests/mock/sysrepo_subscription.cpp
index c74d7af..ba276a7 100644
--- a/tests/mock/sysrepo_subscription.cpp
+++ b/tests/mock/sysrepo_subscription.cpp
@@ -6,6 +6,8 @@
  *
 */
 
+#include <experimental/iterator>
+#include <sstream>
 #include <sysrepo-cpp/Session.hpp>
 #include "sysrepo_subscription.hpp"
 
@@ -94,6 +96,14 @@
         v->set(xpath.c_str(), what.c_str());
     }
 
+    void operator()(const bits_& what)
+    {
+        std::stringstream ss;
+        std::copy(what.m_bits.begin(), what.m_bits.end(), std::experimental::make_ostream_joiner(ss, " "));
+        v->set(xpath.c_str(), ss.str().c_str());
+
+    }
+
     template <typename Type>
     void operator()(const Type what)
     {
diff --git a/tests/pretty_printers.hpp b/tests/pretty_printers.hpp
index 6864443..ab6b917 100644
--- a/tests/pretty_printers.hpp
+++ b/tests/pretty_printers.hpp
@@ -42,7 +42,7 @@
 {
     s << "DatastoreAccess::Tree {\n";
     for (const auto& [xpath, value] : tree) {
-        s << "    {" << xpath << ", " << leafDataToString(value) << "},\n";
+        s << "    {" << xpath << ", " << boost::core::demangle(value.type().name()) << "{" << leafDataToString(value) << "}},\n";
     }
     s << "}\n";
     return s;