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