Fix YangSchema::childNodes with paths with choice
YangSchema::childNodes, if called with a path with a choice segfaulted,
because it was using libyang in a different way, than the rest of the
class. childNodes now uses libyang consistenly with the rest of the
class.
Change-Id: I81f19114a3088994c552c1bb2fd9b4e3bc326196
diff --git a/tests/yang.cpp b/tests/yang.cpp
index 156d94b..d9c2a89 100644
--- a/tests/yang.cpp
+++ b/tests/yang.cpp
@@ -6,6 +6,7 @@
*
*/
+#include <experimental/iterator>
#include "trompeloeil_doctest.h"
#include "yang_schema.hpp"
@@ -251,6 +252,16 @@
})";
+namespace std {
+std::ostream& operator<<(std::ostream& s, const std::set<std::string> set)
+{
+ s << std::endl << "{";
+ std::copy(set.begin(), set.end(), std::experimental::make_ostream_joiner(s, ", "));
+ s << "}" << std::endl;
+ return s;
+}
+}
+
TEST_CASE("yangschema")
{
using namespace std::string_view_literals;
@@ -696,6 +707,12 @@
set = {"bla2"};
}
+ SECTION("example-schema:ethernet")
+ {
+ path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("ethernet")));
+ set = {"ip"};
+ }
+
REQUIRE(ys.childNodes(path, Recursion::NonRecursive) == set);
}
}