Fix leafDataFromValue

Leafrefs were not working correctly, when pointing to a data node not in
the tree. Because of this I had to rework the thing a little bit (I
basically copied the algorithm from cla-sysrepo, where I had the same
issue). I also changed the name. And also added test, both versions of
leafref included.

Funnily enough, it seems that I was already fixing this before, but for
some reason the bug appeared again while using netconf-cli, oh well, now
the tests should cover that hopefully.

Change-Id: I8a102c54bf58a4221610c8a83d26979fb7b4461d
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 448b094..e7570c6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -114,11 +114,15 @@
 
 target_link_libraries(yangaccess PUBLIC datastoreaccess yangschema PRIVATE PkgConfig::LIBYANG)
 
-add_library(yangschema STATIC
-    src/yang_schema.cpp
+add_library(libyangutils
     src/libyang_utils.cpp
     )
-target_link_libraries(yangschema PUBLIC schemas utils PRIVATE PkgConfig::LIBYANG)
+target_link_libraries(libyangutils PUBLIC PkgConfig::LIBYANG)
+
+add_library(yangschema STATIC
+    src/yang_schema.cpp
+    )
+target_link_libraries(yangschema PUBLIC schemas utils libyangutils PRIVATE PkgConfig::LIBYANG)
 
 add_library(parser STATIC
     src/parser.cpp
@@ -287,6 +291,7 @@
     cli_test(yang)
     target_link_libraries(test_yang yangschema)
     cli_test(utils)
+    target_link_libraries(test_utils libyangutils)
     cli_test(path_completion)
     cli_test(command_completion)
     cli_test(set_value_completion)