Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/ |
| 3 | * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/ |
| 4 | * |
| 5 | * Written by Václav Kubernát <kubervac@fit.cvut.cz> |
| 6 | * |
| 7 | */ |
| 8 | |
Václav Kubernát | 26b5608 | 2020-02-03 18:28:56 +0100 | [diff] [blame] | 9 | #include "trompeloeil_doctest.hpp" |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 10 | #include <libyang-cpp/Context.hpp> |
Václav Kubernát | cb3af40 | 2020-02-12 16:49:17 +0100 | [diff] [blame] | 11 | #include "completion.hpp" |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 12 | #include "leaf_data_helpers.hpp" |
Václav Kubernát | 2e4cafe | 2020-11-05 01:53:21 +0100 | [diff] [blame] | 13 | #include "libyang_utils.hpp" |
| 14 | #include "pretty_printers.hpp" |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 15 | #include "utils.hpp" |
| 16 | |
| 17 | TEST_CASE("utils") |
| 18 | { |
Václav Kubernát | a395d33 | 2019-02-13 16:49:20 +0100 | [diff] [blame] | 19 | SECTION("filterByPrefix") |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 20 | { |
Václav Kubernát | cb3af40 | 2020-02-12 16:49:17 +0100 | [diff] [blame] | 21 | std::set<Completion> set{{"ahoj"}, {"coze"}, {"copak"}, {"aha"}, {"polivka"}}; |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 22 | |
Václav Kubernát | cb3af40 | 2020-02-12 16:49:17 +0100 | [diff] [blame] | 23 | REQUIRE((filterByPrefix(set, "a") == std::set<Completion>{{"ahoj"}, {"aha"}})); |
| 24 | REQUIRE((filterByPrefix(set, "ah") == std::set<Completion>{{"ahoj"}, {"aha"}})); |
| 25 | REQUIRE((filterByPrefix(set, "aho") == std::set<Completion>{{"ahoj"}})); |
| 26 | REQUIRE((filterByPrefix(set, "polivka") == std::set<Completion>{{"polivka"}})); |
| 27 | REQUIRE((filterByPrefix(set, "polivkax") == std::set<Completion>{})); |
| 28 | REQUIRE((filterByPrefix(set, "co") == std::set<Completion>{{"copak"}, {"coze"}})); |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 29 | } |
Václav Kubernát | a44bdf2 | 2020-01-24 12:15:31 +0100 | [diff] [blame] | 30 | |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 31 | SECTION("joinPaths") |
| 32 | { |
Václav Kubernát | a44bdf2 | 2020-01-24 12:15:31 +0100 | [diff] [blame] | 33 | std::string prefix, suffix, result; |
| 34 | |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 35 | SECTION("regular") |
| 36 | { |
Václav Kubernát | a44bdf2 | 2020-01-24 12:15:31 +0100 | [diff] [blame] | 37 | prefix = "/example:a"; |
| 38 | suffix = "leaf"; |
| 39 | result = "/example:a/leaf"; |
| 40 | } |
| 41 | |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 42 | SECTION("no prefix - absolute path") |
| 43 | { |
Václav Kubernát | a44bdf2 | 2020-01-24 12:15:31 +0100 | [diff] [blame] | 44 | suffix = "/example:a/leaf"; |
| 45 | result = "/example:a/leaf"; |
| 46 | } |
| 47 | |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 48 | SECTION("no prefix - relative path") |
| 49 | { |
Václav Kubernát | a44bdf2 | 2020-01-24 12:15:31 +0100 | [diff] [blame] | 50 | suffix = "example:a/leaf"; |
| 51 | result = "example:a/leaf"; |
| 52 | } |
| 53 | |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 54 | SECTION("no suffix") |
| 55 | { |
Václav Kubernát | a44bdf2 | 2020-01-24 12:15:31 +0100 | [diff] [blame] | 56 | prefix = "/example:a/leaf"; |
| 57 | result = "/example:a/leaf"; |
| 58 | } |
| 59 | |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 60 | SECTION("at root") |
| 61 | { |
Václav Kubernát | a44bdf2 | 2020-01-24 12:15:31 +0100 | [diff] [blame] | 62 | prefix = "/"; |
| 63 | suffix = "example:a"; |
| 64 | result = "/example:a"; |
| 65 | } |
| 66 | |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 67 | SECTION("trailing slash") |
| 68 | { |
Václav Kubernát | a44bdf2 | 2020-01-24 12:15:31 +0100 | [diff] [blame] | 69 | prefix = "/example:a"; |
| 70 | suffix = "/"; |
| 71 | result = "/example:a/"; |
| 72 | } |
| 73 | |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 74 | SECTION("prefix ends with slash") |
| 75 | { |
Václav Kubernát | a44bdf2 | 2020-01-24 12:15:31 +0100 | [diff] [blame] | 76 | prefix = "/example:a/"; |
| 77 | suffix = "leaf"; |
| 78 | result = "/example:a/leaf"; |
| 79 | } |
| 80 | |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 81 | SECTION("suffix starts with slash") |
| 82 | { |
Václav Kubernát | a44bdf2 | 2020-01-24 12:15:31 +0100 | [diff] [blame] | 83 | prefix = "/example:a"; |
| 84 | suffix = "/leaf"; |
| 85 | result = "/example:a/leaf"; |
| 86 | } |
| 87 | |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 88 | SECTION("slashes all the way to eleven") |
| 89 | { |
Václav Kubernát | a44bdf2 | 2020-01-24 12:15:31 +0100 | [diff] [blame] | 90 | prefix = "/example:a/"; |
| 91 | suffix = "/leaf"; |
| 92 | result = "/example:a/leaf"; |
| 93 | } |
| 94 | |
| 95 | REQUIRE(joinPaths(prefix, suffix) == result); |
| 96 | } |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 97 | |
| 98 | SECTION("leafDataTypeToString") |
| 99 | { |
| 100 | yang::LeafDataType type; |
| 101 | std::string expected; |
| 102 | SECTION("union") |
| 103 | { |
| 104 | type = yang::Union{{ |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 105 | yang::TypeInfo{yang::String{}}, |
| 106 | yang::TypeInfo{createEnum({"foo", "bar"})}, |
| 107 | yang::TypeInfo{yang::Int8{}}, |
| 108 | yang::TypeInfo{yang::Int64{}}, |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 109 | }}; |
| 110 | expected = "a string, an enum, an 8-bit integer, a 64-bit integer"; |
| 111 | } |
| 112 | |
| 113 | REQUIRE(leafDataTypeToString(type) == expected); |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 114 | } |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 115 | } |
Václav Kubernát | 2e4cafe | 2020-11-05 01:53:21 +0100 | [diff] [blame] | 116 | |
| 117 | const auto schema = R"( |
| 118 | module test-schema { |
| 119 | namespace "http://example.com/ayyyy"; |
| 120 | prefix AHOJ; |
| 121 | |
| 122 | leaf int8 { |
| 123 | type int8; |
| 124 | } |
| 125 | leaf int16 { |
| 126 | type int16; |
| 127 | } |
| 128 | leaf int32 { |
| 129 | type int32; |
| 130 | } |
| 131 | leaf int64 { |
| 132 | type int64; |
| 133 | } |
| 134 | leaf uint8 { |
| 135 | type uint8; |
| 136 | } |
| 137 | leaf uint16 { |
| 138 | type uint16; |
| 139 | } |
| 140 | leaf uint32 { |
| 141 | type uint32; |
| 142 | } |
| 143 | leaf uint64 { |
| 144 | type uint64; |
| 145 | } |
| 146 | leaf boolean { |
| 147 | type boolean; |
| 148 | } |
| 149 | leaf string { |
| 150 | type string; |
| 151 | } |
| 152 | leaf enum { |
| 153 | type enumeration { |
| 154 | enum A; |
| 155 | enum B; |
| 156 | enum C; |
| 157 | } |
| 158 | } |
| 159 | identity food; |
| 160 | identity apple { |
| 161 | base "food"; |
| 162 | } |
| 163 | leaf identityRef { |
| 164 | type identityref { |
| 165 | base "food"; |
| 166 | } |
| 167 | } |
| 168 | leaf binary { |
| 169 | type binary; |
| 170 | } |
| 171 | leaf empty { |
| 172 | type empty; |
| 173 | } |
| 174 | leaf bits { |
| 175 | type bits { |
| 176 | bit a; |
| 177 | bit b; |
| 178 | bit AHOJ; |
| 179 | } |
| 180 | } |
Václav Kubernát | d4800e5 | 2020-11-09 10:58:12 +0100 | [diff] [blame] | 181 | typedef capabilitiesType { |
| 182 | type bits { |
| 183 | bit router; |
| 184 | bit switch; |
| 185 | bit hub; |
| 186 | } |
| 187 | } |
| 188 | leaf capabilities { |
| 189 | type capabilitiesType; |
| 190 | } |
Václav Kubernát | 2e4cafe | 2020-11-05 01:53:21 +0100 | [diff] [blame] | 191 | leaf dec64 { |
| 192 | type decimal64 { |
| 193 | fraction-digits 5; |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | list stuff { |
| 198 | key "name"; |
| 199 | leaf name { |
| 200 | type string; |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | leaf leafRefPresent { |
| 205 | type leafref { |
| 206 | path ../stuff/name; |
| 207 | } |
| 208 | } |
| 209 | |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 210 | container users { |
| 211 | config false; |
| 212 | list userList { |
| 213 | leaf name { |
| 214 | type string; |
| 215 | } |
| 216 | } |
| 217 | } |
Václav Kubernát | 2e4cafe | 2020-11-05 01:53:21 +0100 | [diff] [blame] | 218 | } |
| 219 | )"; |
| 220 | |
| 221 | const auto data = R"( |
| 222 | { |
| 223 | "test-schema:int8": 8, |
| 224 | "test-schema:int16": 300, |
| 225 | "test-schema:int32": -300, |
Jan Kundrát | 6c34e9f | 2021-01-27 12:58:51 +0100 | [diff] [blame] | 226 | "test-schema:int64": "-999999999999999", |
Václav Kubernát | 2e4cafe | 2020-11-05 01:53:21 +0100 | [diff] [blame] | 227 | "test-schema:uint8": 8, |
| 228 | "test-schema:uint16": 300, |
| 229 | "test-schema:uint32": 300, |
Jan Kundrát | 6c34e9f | 2021-01-27 12:58:51 +0100 | [diff] [blame] | 230 | "test-schema:uint64": "999999999999999", |
Václav Kubernát | 2e4cafe | 2020-11-05 01:53:21 +0100 | [diff] [blame] | 231 | "test-schema:boolean": true, |
| 232 | "test-schema:string": "AHOJ", |
| 233 | "test-schema:enum": "A", |
| 234 | "test-schema:identityRef": "apple", |
| 235 | "test-schema:binary": "QUhPSgo=", |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 236 | "test-schema:empty": [null], |
Václav Kubernát | 2e4cafe | 2020-11-05 01:53:21 +0100 | [diff] [blame] | 237 | "test-schema:bits": "a AHOJ", |
Václav Kubernát | d4800e5 | 2020-11-09 10:58:12 +0100 | [diff] [blame] | 238 | "test-schema:capabilities": "switch hub", |
Václav Kubernát | 2e4cafe | 2020-11-05 01:53:21 +0100 | [diff] [blame] | 239 | "test-schema:dec64": "43242.43260", |
| 240 | "test-schema:stuff": [ |
| 241 | { |
| 242 | "name": "Xaver" |
| 243 | } |
| 244 | ], |
| 245 | "test-schema:leafRefPresent": "Xaver", |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 246 | "test-schema:users": { |
| 247 | "userList": [ |
| 248 | { |
| 249 | "name": "John" |
| 250 | }, |
| 251 | { |
| 252 | "name": "Aneta" |
| 253 | }, |
| 254 | { |
| 255 | "name": "Aneta" |
| 256 | } |
| 257 | ] |
| 258 | } |
Václav Kubernát | 2e4cafe | 2020-11-05 01:53:21 +0100 | [diff] [blame] | 259 | } |
| 260 | )"; |
| 261 | |
| 262 | |
| 263 | TEST_CASE("libyang_utils") |
| 264 | { |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 265 | libyang::Context ctx; |
| 266 | ctx.parseModuleMem(schema, libyang::SchemaFormat::YANG); |
| 267 | auto dataNode = ctx.parseDataMem(data, libyang::DataFormat::JSON, std::nullopt, libyang::ValidationOptions::Present); |
Václav Kubernát | 2e4cafe | 2020-11-05 01:53:21 +0100 | [diff] [blame] | 268 | |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 269 | SECTION("leafValueFromNode") |
| 270 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 271 | std::string path; |
| 272 | leaf_data_ expectedLeafData; |
Václav Kubernát | 2e4cafe | 2020-11-05 01:53:21 +0100 | [diff] [blame] | 273 | |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 274 | SECTION("test-schema:int8") |
| 275 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 276 | path = "test-schema:int8"; |
| 277 | expectedLeafData = int8_t{8}; |
| 278 | } |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 279 | SECTION("test-schema:int16") |
| 280 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 281 | path = "test-schema:int16"; |
| 282 | expectedLeafData = int16_t{300}; |
| 283 | } |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 284 | SECTION("test-schema:int32") |
| 285 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 286 | path = "test-schema:int32"; |
| 287 | expectedLeafData = int32_t{-300}; |
| 288 | } |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 289 | SECTION("test-schema:int64") |
| 290 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 291 | path = "test-schema:int64"; |
| 292 | expectedLeafData = int64_t{-999999999999999}; |
| 293 | } |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 294 | SECTION("test-schema:uint8") |
| 295 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 296 | path = "test-schema:uint8"; |
| 297 | expectedLeafData = uint8_t{8}; |
| 298 | } |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 299 | SECTION("test-schema:uint16") |
| 300 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 301 | path = "test-schema:uint16"; |
| 302 | expectedLeafData = uint16_t{300}; |
| 303 | } |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 304 | SECTION("test-schema:uint32") |
| 305 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 306 | path = "test-schema:uint32"; |
| 307 | expectedLeafData = uint32_t{300}; |
| 308 | } |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 309 | SECTION("test-schema:uint64") |
| 310 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 311 | path = "test-schema:uint64"; |
| 312 | expectedLeafData = uint64_t{999999999999999}; |
| 313 | } |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 314 | SECTION("test-schema:boolean") |
| 315 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 316 | path = "test-schema:boolean"; |
| 317 | expectedLeafData = true; |
| 318 | } |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 319 | SECTION("test-schema:string") |
| 320 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 321 | path = "test-schema:string"; |
| 322 | expectedLeafData = std::string{"AHOJ"}; |
| 323 | } |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 324 | SECTION("test-schema:enum") |
| 325 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 326 | path = "test-schema:enum"; |
| 327 | expectedLeafData = enum_{"A"}; |
| 328 | } |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 329 | SECTION("test-schema:identityRef") |
| 330 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 331 | path = "test-schema:identityRef"; |
| 332 | expectedLeafData = identityRef_{"test-schema", "apple"}; |
| 333 | } |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 334 | SECTION("test-schema:binary") |
| 335 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 336 | path = "test-schema:binary"; |
| 337 | expectedLeafData = binary_{"QUhPSgo="}; |
| 338 | } |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 339 | SECTION("test-schema:empty") |
| 340 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 341 | path = "test-schema:empty"; |
| 342 | expectedLeafData = empty_{}; |
| 343 | } |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 344 | SECTION("test-schema:bits") |
| 345 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 346 | path = "test-schema:bits"; |
| 347 | expectedLeafData = bits_{{"a", "AHOJ"}}; |
| 348 | } |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 349 | SECTION("test-schema:dec64") |
| 350 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 351 | path = "test-schema:dec64"; |
| 352 | expectedLeafData = 43242.43260; |
| 353 | } |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 354 | SECTION("test-schema:leafRefPresent") |
| 355 | { |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 356 | path = "test-schema:leafRefPresent"; |
| 357 | expectedLeafData = std::string{"Xaver"}; |
| 358 | } |
Václav Kubernát | 2e4cafe | 2020-11-05 01:53:21 +0100 | [diff] [blame] | 359 | |
Jan Kundrát | f59b83c | 2022-03-18 18:12:08 +0100 | [diff] [blame^] | 360 | auto leaf = dataNode->findPath("/" + path); |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 361 | REQUIRE(leafValueFromNode(leaf->asTerm()) == expectedLeafData); |
Václav Kubernát | 2e4cafe | 2020-11-05 01:53:21 +0100 | [diff] [blame] | 362 | } |
| 363 | |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 364 | SECTION("lyNodesToTree") |
| 365 | { |
| 366 | DatastoreAccess::Tree expected{ |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 367 | {"/test-schema:int8", int8_t{8}}, |
| 368 | {"/test-schema:int16", int16_t{300}}, |
| 369 | {"/test-schema:int32", int32_t{-300}}, |
| 370 | {"/test-schema:int64", int64_t{-999999999999999}}, |
| 371 | {"/test-schema:uint8", uint8_t{8}}, |
| 372 | {"/test-schema:uint16", uint16_t{300}}, |
| 373 | {"/test-schema:uint32", uint32_t{300}}, |
| 374 | {"/test-schema:uint64", uint64_t{999999999999999}}, |
| 375 | {"/test-schema:boolean", true}, |
| 376 | {"/test-schema:string", std::string{"AHOJ"}}, |
| 377 | {"/test-schema:enum", enum_{"A"}}, |
| 378 | {"/test-schema:identityRef", identityRef_{"test-schema", "apple"}}, |
| 379 | {"/test-schema:binary", binary_{"QUhPSgo="}}, |
| 380 | {"/test-schema:empty", empty_{}}, |
| 381 | {"/test-schema:bits", bits_{{"a", "AHOJ"}}}, |
Václav Kubernát | d4800e5 | 2020-11-09 10:58:12 +0100 | [diff] [blame] | 382 | {"/test-schema:capabilities", bits_{{"switch", "hub"}}}, |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 383 | {"/test-schema:dec64", 43242.432600}, |
| 384 | {"/test-schema:stuff[name='Xaver']", special_{SpecialValue::List}}, |
| 385 | {"/test-schema:stuff[name='Xaver']/name", std::string{"Xaver"}}, |
| 386 | {"/test-schema:leafRefPresent", std::string{"Xaver"}}, |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 387 | {"/test-schema:users/userList[1]", special_{SpecialValue::List}}, |
| 388 | {"/test-schema:users/userList[1]/name", std::string{"John"}}, |
| 389 | {"/test-schema:users/userList[2]", special_{SpecialValue::List}}, |
| 390 | {"/test-schema:users/userList[2]/name", std::string{"Aneta"}}, |
| 391 | {"/test-schema:users/userList[3]", special_{SpecialValue::List}}, |
| 392 | {"/test-schema:users/userList[3]/name", std::string{"Aneta"}}, |
| 393 | }; |
| 394 | |
| 395 | DatastoreAccess::Tree tree; |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 396 | lyNodesToTree(tree, dataNode->siblings()); |
Václav Kubernát | 61d92d7 | 2020-11-06 03:14:18 +0100 | [diff] [blame] | 397 | REQUIRE(tree == expected); |
| 398 | } |
Václav Kubernát | 2e4cafe | 2020-11-05 01:53:21 +0100 | [diff] [blame] | 399 | } |