Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [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 | 47a3f67 | 2019-11-08 15:42:43 +0100 | [diff] [blame] | 9 | #include <experimental/iterator> |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 10 | #include "leaf_data_helpers.hpp" |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 11 | #include "pretty_printers.hpp" |
Václav Kubernát | 26b5608 | 2020-02-03 18:28:56 +0100 | [diff] [blame] | 12 | #include "trompeloeil_doctest.hpp" |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 13 | #include "yang_schema.hpp" |
| 14 | |
Václav Kubernát | 4f77a25 | 2019-02-19 16:51:30 +0100 | [diff] [blame] | 15 | const char* second_schema = R"( |
| 16 | module second-schema { |
| 17 | namespace "http://example.com/nevim"; |
| 18 | prefix second; |
| 19 | |
| 20 | import example-schema { |
| 21 | prefix "example"; |
| 22 | } |
| 23 | |
Václav Kubernát | eeb3884 | 2019-03-20 19:46:05 +0100 | [diff] [blame] | 24 | identity pineapple { |
| 25 | base "example:fruit"; |
| 26 | } |
| 27 | |
Václav Kubernát | 4f77a25 | 2019-02-19 16:51:30 +0100 | [diff] [blame] | 28 | augment /example:a { |
| 29 | container augmentedContainer { |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | container bla { |
| 34 | container bla2 { |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | )"; |
| 39 | |
Václav Kubernát | 82d7463 | 2020-05-11 15:59:53 +0200 | [diff] [blame] | 40 | const char* included_submodule = R"( |
| 41 | submodule sub-module { |
| 42 | yang-version 1.1; |
| 43 | |
| 44 | belongs-to example-schema { |
| 45 | prefix sub; |
| 46 | } |
| 47 | |
| 48 | leaf subLeaf { |
| 49 | type string; |
| 50 | } |
| 51 | } |
| 52 | )"; |
| 53 | |
Václav Kubernát | 4f77a25 | 2019-02-19 16:51:30 +0100 | [diff] [blame] | 54 | const char* example_schema = R"( |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 55 | module example-schema { |
Václav Kubernát | 6a713d6 | 2018-10-03 18:47:34 +0200 | [diff] [blame] | 56 | yang-version 1.1; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 57 | namespace "http://example.com/example-sports"; |
| 58 | prefix coze; |
| 59 | |
Václav Kubernát | 82d7463 | 2020-05-11 15:59:53 +0200 | [diff] [blame] | 60 | include sub-module; |
| 61 | |
Václav Kubernát | eeb3884 | 2019-03-20 19:46:05 +0100 | [diff] [blame] | 62 | identity drink { |
| 63 | } |
| 64 | |
| 65 | identity voda { |
| 66 | base "drink"; |
| 67 | } |
| 68 | |
| 69 | identity food { |
| 70 | } |
| 71 | |
| 72 | identity fruit { |
| 73 | base "food"; |
| 74 | } |
| 75 | |
| 76 | identity pizza { |
| 77 | base "food"; |
| 78 | } |
| 79 | |
| 80 | identity hawaii { |
| 81 | base "pizza"; |
| 82 | } |
| 83 | |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 84 | container a { |
| 85 | container a2 { |
| 86 | container a3 { |
| 87 | presence true; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | leaf leafa { |
| 92 | type string; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | container b { |
| 97 | container b2 { |
| 98 | presence true; |
| 99 | container b3 { |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | leaf leafString { |
| 105 | type string; |
| 106 | } |
| 107 | |
| 108 | leaf leafDecimal { |
| 109 | type decimal64 { |
| 110 | fraction-digits 5; |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | leaf leafBool { |
| 115 | type boolean; |
| 116 | } |
| 117 | |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 118 | leaf leafInt8 { |
| 119 | type int8; |
| 120 | } |
| 121 | |
| 122 | leaf leafUint8 { |
| 123 | type uint8; |
| 124 | } |
| 125 | |
| 126 | leaf leafInt16 { |
| 127 | type int16; |
| 128 | } |
| 129 | |
| 130 | leaf leafUint16 { |
| 131 | type uint16; |
| 132 | } |
| 133 | |
| 134 | leaf leafInt32 { |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 135 | description "A 32-bit integer leaf."; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 136 | type int32; |
| 137 | } |
| 138 | |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 139 | leaf leafUint32 { |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 140 | type uint32; |
| 141 | } |
| 142 | |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 143 | leaf leafInt64 { |
| 144 | type int64; |
| 145 | } |
| 146 | |
| 147 | leaf leafUint64 { |
| 148 | type uint64; |
Václav Kubernát | b1a75c6 | 2020-04-21 15:20:16 +0200 | [diff] [blame] | 149 | default 9001; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 150 | } |
| 151 | |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 152 | leaf leafEnum { |
| 153 | type enumeration { |
| 154 | enum lol; |
| 155 | enum data; |
| 156 | enum coze; |
| 157 | } |
| 158 | } |
| 159 | |
Václav Kubernát | 6a713d6 | 2018-10-03 18:47:34 +0200 | [diff] [blame] | 160 | typedef enumTypedef { |
| 161 | type enumeration { |
| 162 | enum lol; |
| 163 | enum data; |
| 164 | enum coze; |
| 165 | } |
Václav Kubernát | b1a75c6 | 2020-04-21 15:20:16 +0200 | [diff] [blame] | 166 | default data; |
Václav Kubernát | 6a713d6 | 2018-10-03 18:47:34 +0200 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | typedef enumTypedefRestricted { |
| 170 | type enumTypedef { |
| 171 | enum lol; |
| 172 | enum data; |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | leaf leafEnumTypedef { |
| 177 | type enumTypedef; |
| 178 | } |
| 179 | |
| 180 | leaf leafEnumTypedefRestricted { |
| 181 | type enumTypedef { |
| 182 | enum data; |
| 183 | enum coze; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | leaf leafEnumTypedefRestricted2 { |
| 188 | type enumTypedefRestricted; |
| 189 | } |
| 190 | |
Václav Kubernát | eeb3884 | 2019-03-20 19:46:05 +0100 | [diff] [blame] | 191 | leaf foodIdentLeaf { |
| 192 | type identityref { |
| 193 | base "food"; |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | leaf pizzaIdentLeaf { |
| 198 | type identityref { |
| 199 | base "pizza"; |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | leaf foodDrinkIdentLeaf { |
| 204 | type identityref { |
| 205 | base "food"; |
| 206 | base "drink"; |
| 207 | } |
| 208 | } |
| 209 | |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 210 | list _list { |
| 211 | key number; |
| 212 | |
| 213 | leaf number { |
| 214 | type int32; |
| 215 | } |
| 216 | |
| 217 | container contInList { |
| 218 | presence true; |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | list twoKeyList { |
| 223 | key "name number"; |
| 224 | |
| 225 | leaf number { |
| 226 | type int32; |
| 227 | } |
| 228 | |
| 229 | leaf name { |
| 230 | type string; |
| 231 | } |
| 232 | } |
Václav Kubernát | 7d82da7 | 2019-04-11 15:16:38 +0200 | [diff] [blame] | 233 | |
| 234 | grouping arithmeticFlags { |
| 235 | leaf carry { |
| 236 | type boolean; |
| 237 | } |
| 238 | leaf zero { |
| 239 | type boolean; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | grouping flags { |
| 244 | leaf direction { |
| 245 | type boolean; |
| 246 | } |
| 247 | leaf interrupt { |
| 248 | type boolean; |
| 249 | } |
| 250 | |
| 251 | uses arithmeticFlags; |
| 252 | } |
| 253 | |
| 254 | uses flags; |
Václav Kubernát | 280df4a | 2019-11-01 14:46:34 +0100 | [diff] [blame] | 255 | |
| 256 | choice interface { |
| 257 | case caseLoopback { |
| 258 | container loopback { |
| 259 | leaf ip { |
| 260 | type string; |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | case caseEthernet { |
| 266 | container ethernet { |
| 267 | leaf ip { |
| 268 | type string; |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | |
Václav Kubernát | a38d417 | 2019-11-04 12:36:39 +0100 | [diff] [blame] | 274 | feature bigPizzas; |
| 275 | |
| 276 | leaf pizzaSize { |
| 277 | type enumeration { |
| 278 | enum large { |
| 279 | if-feature "bigPizzas"; |
| 280 | } |
| 281 | enum medium; |
| 282 | enum small; |
| 283 | } |
| 284 | } |
| 285 | |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 286 | leaf length { |
| 287 | type int32; |
| 288 | units "m"; |
| 289 | } |
| 290 | |
| 291 | leaf wavelength { |
| 292 | type decimal64 { |
| 293 | fraction-digits 10; |
| 294 | } |
| 295 | units "nm"; |
| 296 | } |
| 297 | |
| 298 | typedef seconds { |
| 299 | type int32; |
| 300 | units "s"; |
| 301 | } |
| 302 | |
| 303 | leaf duration { |
| 304 | type seconds; |
| 305 | } |
| 306 | |
| 307 | leaf another-duration { |
| 308 | type seconds; |
| 309 | units "vt"; |
| 310 | } |
| 311 | |
Václav Kubernát | bd5e3c2 | 2020-02-19 15:22:00 +0100 | [diff] [blame] | 312 | leaf activeNumber { |
| 313 | type leafref { |
| 314 | path "/_list/number"; |
| 315 | } |
| 316 | } |
| 317 | |
Václav Kubernát | fa81c8c | 2020-02-13 17:22:46 +0100 | [diff] [blame] | 318 | rpc myRpc {} |
| 319 | |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 320 | leaf numberOrString { |
| 321 | type union { |
| 322 | type int32; |
| 323 | type string; |
| 324 | } |
| 325 | description "Can be an int32 or a string."; |
| 326 | } |
| 327 | |
| 328 | list portSettings { |
| 329 | key "port"; |
| 330 | leaf port { |
| 331 | type enumeration { |
| 332 | enum eth0; |
| 333 | enum eth1; |
| 334 | enum eth2; |
| 335 | } |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | feature weirdPortNames; |
| 340 | |
| 341 | list portMapping { |
| 342 | key "port"; |
| 343 | leaf port { |
| 344 | type enumeration { |
| 345 | enum WEIRD { |
| 346 | if-feature "weirdPortNames"; |
| 347 | } |
| 348 | enum utf2; |
| 349 | enum utf3; |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | leaf activeMappedPort { |
| 355 | type leafref { |
| 356 | path "../portMapping/port"; |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | leaf activePort { |
| 361 | type union { |
| 362 | type enumeration { |
| 363 | enum wlan0; |
| 364 | enum wlan1; |
| 365 | } |
| 366 | type leafref { |
| 367 | path "../portSettings/port"; |
| 368 | } |
| 369 | type leafref { |
| 370 | path "../activeMappedPort"; |
| 371 | } |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 372 | type empty; |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 373 | } |
| 374 | } |
| 375 | |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 376 | leaf dummyLeaf { |
| 377 | type empty; |
| 378 | } |
| 379 | |
Václav Kubernát | 0599e9f | 2020-04-21 09:51:33 +0200 | [diff] [blame] | 380 | leaf clockSpeed { |
| 381 | type int64; |
| 382 | config false; |
| 383 | } |
| 384 | |
| 385 | container systemStats { |
| 386 | config false; |
| 387 | leaf upTime { |
| 388 | type uint64; |
| 389 | } |
| 390 | } |
| 391 | |
Václav Kubernát | a1c4c9e | 2020-04-22 00:37:52 +0200 | [diff] [blame] | 392 | leaf obsoleteLeaf { |
| 393 | type int32; |
| 394 | status obsolete; |
| 395 | } |
| 396 | |
| 397 | leaf deprecatedLeaf { |
| 398 | type int32; |
| 399 | status deprecated; |
| 400 | } |
| 401 | |
| 402 | typedef deprecatedType { |
| 403 | type int32; |
| 404 | status deprecated; |
| 405 | } |
| 406 | |
| 407 | leaf obsoleteLeafWithDeprecatedType { |
| 408 | type deprecatedType; |
| 409 | status obsolete; |
| 410 | } |
| 411 | |
| 412 | typedef obsoleteType { |
| 413 | type int32; |
| 414 | status obsolete; |
| 415 | } |
| 416 | |
| 417 | leaf obsoleteLeafWithObsoleteType { |
| 418 | type deprecatedType; |
| 419 | status obsolete; |
| 420 | } |
| 421 | |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 422 | })"; |
| 423 | |
Václav Kubernát | 47a3f67 | 2019-11-08 15:42:43 +0100 | [diff] [blame] | 424 | namespace std { |
| 425 | std::ostream& operator<<(std::ostream& s, const std::set<std::string> set) |
| 426 | { |
| 427 | s << std::endl << "{"; |
| 428 | std::copy(set.begin(), set.end(), std::experimental::make_ostream_joiner(s, ", ")); |
| 429 | s << "}" << std::endl; |
| 430 | return s; |
| 431 | } |
| 432 | } |
| 433 | |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 434 | TEST_CASE("yangschema") |
| 435 | { |
Václav Kubernát | 82d7463 | 2020-05-11 15:59:53 +0200 | [diff] [blame] | 436 | using namespace std::string_literals; |
Václav Kubernát | 4f77a25 | 2019-02-19 16:51:30 +0100 | [diff] [blame] | 437 | using namespace std::string_view_literals; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 438 | YangSchema ys; |
Václav Kubernát | 82d7463 | 2020-05-11 15:59:53 +0200 | [diff] [blame] | 439 | ys.registerModuleCallback([]([[maybe_unused]] auto modName, auto, auto subModule, auto) { |
| 440 | if (modName != "example-schema"sv) { |
| 441 | throw std::logic_error("unrecognized module "s + modName); |
| 442 | } |
| 443 | if (subModule == nullptr) { |
| 444 | return example_schema; |
| 445 | } |
| 446 | if (subModule == "sub-module"sv) { |
| 447 | return included_submodule; |
| 448 | } |
| 449 | |
| 450 | throw std::logic_error("unrecognized submodule "s + subModule); |
Václav Kubernát | 4f77a25 | 2019-02-19 16:51:30 +0100 | [diff] [blame] | 451 | }); |
| 452 | ys.addSchemaString(second_schema); |
| 453 | |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 454 | schemaPath_ path{Scope::Absolute, {}}; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 455 | ModuleNodePair node; |
| 456 | |
| 457 | SECTION("positive") |
| 458 | { |
| 459 | SECTION("isContainer") |
| 460 | { |
| 461 | SECTION("example-schema:a") |
| 462 | { |
| 463 | node.first = "example-schema"; |
| 464 | node.second = "a"; |
| 465 | } |
| 466 | |
| 467 | SECTION("example-schema:a/a2") |
| 468 | { |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 469 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a"))); |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 470 | node.second = "a2"; |
| 471 | } |
| 472 | |
Václav Kubernát | 280df4a | 2019-11-01 14:46:34 +0100 | [diff] [blame] | 473 | SECTION("example-schema:ethernet") |
| 474 | { |
| 475 | node.first = "example-schema"; |
| 476 | node.second = "ethernet"; |
| 477 | } |
| 478 | |
| 479 | SECTION("example-schema:loopback") |
| 480 | { |
| 481 | node.first = "example-schema"; |
| 482 | node.second = "loopback"; |
| 483 | } |
| 484 | |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 485 | REQUIRE(ys.isContainer(path, node)); |
| 486 | } |
| 487 | SECTION("isLeaf") |
| 488 | { |
| 489 | SECTION("example-schema:leafString") |
| 490 | { |
| 491 | node.first = "example-schema"; |
| 492 | node.second = "leafString"; |
| 493 | } |
| 494 | |
| 495 | SECTION("example-schema:a/leafa") |
| 496 | { |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 497 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a"))); |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 498 | node.first = "example-schema"; |
| 499 | node.second = "leafa"; |
| 500 | } |
| 501 | |
Václav Kubernát | 7d82da7 | 2019-04-11 15:16:38 +0200 | [diff] [blame] | 502 | SECTION("example-schema:carry") |
| 503 | { |
| 504 | node.first = "example-schema"; |
| 505 | node.second = "carry"; |
| 506 | } |
| 507 | |
| 508 | SECTION("example-schema:zero") |
| 509 | { |
| 510 | node.first = "example-schema"; |
| 511 | node.second = "zero"; |
| 512 | } |
| 513 | |
| 514 | SECTION("example-schema:direction") |
| 515 | { |
| 516 | node.first = "example-schema"; |
| 517 | node.second = "direction"; |
| 518 | } |
| 519 | |
| 520 | SECTION("example-schema:interrupt") |
| 521 | { |
| 522 | node.first = "example-schema"; |
| 523 | node.second = "interrupt"; |
| 524 | } |
| 525 | |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 526 | REQUIRE(ys.isLeaf(path, node)); |
| 527 | } |
| 528 | SECTION("isModule") |
| 529 | { |
Václav Kubernát | 75877de | 2019-11-20 17:43:02 +0100 | [diff] [blame] | 530 | REQUIRE(ys.isModule("example-schema")); |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 531 | } |
| 532 | SECTION("isList") |
| 533 | { |
| 534 | SECTION("example-schema:_list") |
| 535 | { |
| 536 | node.first = "example-schema"; |
| 537 | node.second = "_list"; |
| 538 | } |
| 539 | |
| 540 | SECTION("example-schema:twoKeyList") |
| 541 | { |
| 542 | node.first = "example-schema"; |
| 543 | node.second = "twoKeyList"; |
| 544 | } |
| 545 | |
| 546 | REQUIRE(ys.isList(path, node)); |
| 547 | } |
| 548 | SECTION("isPresenceContainer") |
| 549 | { |
| 550 | SECTION("example-schema:a/a2/a3") |
| 551 | { |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 552 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a"))); |
| 553 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a2"))); |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 554 | node.second = "a3"; |
| 555 | } |
| 556 | |
| 557 | REQUIRE(ys.isPresenceContainer(path, node)); |
| 558 | } |
Václav Kubernát | eeb3884 | 2019-03-20 19:46:05 +0100 | [diff] [blame] | 559 | |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 560 | SECTION("listHasKey") |
| 561 | { |
| 562 | std::string key; |
| 563 | |
| 564 | SECTION("_list") |
| 565 | { |
| 566 | node.first = "example-schema"; |
| 567 | node.second = "_list"; |
| 568 | SECTION("number") |
| 569 | key = "number"; |
| 570 | } |
| 571 | |
| 572 | SECTION("twoKeyList") |
| 573 | { |
| 574 | node.first = "example-schema"; |
| 575 | node.second = "twoKeyList"; |
| 576 | SECTION("number") |
| 577 | key = "number"; |
| 578 | SECTION("name") |
| 579 | key = "name"; |
| 580 | } |
| 581 | |
| 582 | REQUIRE(ys.listHasKey(path, node, key)); |
| 583 | } |
| 584 | SECTION("listKeys") |
| 585 | { |
| 586 | std::set<std::string> set; |
| 587 | |
| 588 | SECTION("_list") |
| 589 | { |
| 590 | set = {"number"}; |
| 591 | node.first = "example-schema"; |
| 592 | node.second = "_list"; |
| 593 | } |
| 594 | |
| 595 | SECTION("twoKeyList") |
| 596 | { |
| 597 | set = {"number", "name"}; |
| 598 | node.first = "example-schema"; |
| 599 | node.second = "twoKeyList"; |
| 600 | } |
| 601 | |
| 602 | REQUIRE(ys.listKeys(path, node) == set); |
| 603 | } |
| 604 | SECTION("leafType") |
| 605 | { |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 606 | yang::LeafDataType type; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 607 | |
| 608 | SECTION("leafString") |
| 609 | { |
| 610 | node.first = "example-schema"; |
| 611 | node.second = "leafString"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 612 | type = yang::String{}; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | SECTION("leafDecimal") |
| 616 | { |
| 617 | node.first = "example-schema"; |
| 618 | node.second = "leafDecimal"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 619 | type = yang::Decimal{}; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 620 | } |
| 621 | |
| 622 | SECTION("leafBool") |
| 623 | { |
| 624 | node.first = "example-schema"; |
| 625 | node.second = "leafBool"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 626 | type = yang::Bool{}; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 627 | } |
| 628 | |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 629 | SECTION("leafInt8") |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 630 | { |
| 631 | node.first = "example-schema"; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 632 | node.second = "leafInt8"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 633 | type = yang::Int8{}; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 634 | } |
| 635 | |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 636 | SECTION("leafUint8") |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 637 | { |
| 638 | node.first = "example-schema"; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 639 | node.second = "leafUint8"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 640 | type = yang::Uint8{}; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 641 | } |
| 642 | |
Václav Kubernát | b6d0275 | 2020-04-03 00:25:10 +0200 | [diff] [blame] | 643 | SECTION("leafInt16") |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 644 | { |
| 645 | node.first = "example-schema"; |
| 646 | node.second = "leafInt16"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 647 | type = yang::Int16{}; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 648 | } |
| 649 | |
| 650 | SECTION("leafUint16") |
| 651 | { |
| 652 | node.first = "example-schema"; |
| 653 | node.second = "leafUint16"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 654 | type = yang::Uint16{}; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 655 | } |
| 656 | |
| 657 | SECTION("leafInt32") |
| 658 | { |
| 659 | node.first = "example-schema"; |
| 660 | node.second = "leafInt32"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 661 | type = yang::Int32{}; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | SECTION("leafUint32") |
| 665 | { |
| 666 | node.first = "example-schema"; |
| 667 | node.second = "leafUint32"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 668 | type = yang::Uint32{}; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 669 | } |
| 670 | |
| 671 | SECTION("leafInt64") |
| 672 | { |
| 673 | node.first = "example-schema"; |
| 674 | node.second = "leafInt64"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 675 | type = yang::Int64{}; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 676 | } |
| 677 | |
| 678 | SECTION("leafUint64") |
| 679 | { |
| 680 | node.first = "example-schema"; |
| 681 | node.second = "leafUint64"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 682 | type = yang::Uint64{}; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 683 | } |
| 684 | |
| 685 | SECTION("leafEnum") |
| 686 | { |
| 687 | node.first = "example-schema"; |
| 688 | node.second = "leafEnum"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 689 | type = createEnum({"lol", "data", "coze"}); |
| 690 | } |
| 691 | |
| 692 | SECTION("leafEnumTypedef") |
| 693 | { |
| 694 | node.first = "example-schema"; |
| 695 | node.second = "leafEnumTypedef"; |
| 696 | type = createEnum({"lol", "data", "coze"}); |
| 697 | } |
| 698 | |
| 699 | SECTION("leafEnumTypedefRestricted") |
| 700 | { |
| 701 | node.first = "example-schema"; |
| 702 | node.second = "leafEnumTypedefRestricted"; |
| 703 | type = createEnum({"data", "coze"}); |
| 704 | } |
| 705 | |
| 706 | SECTION("leafEnumTypedefRestricted2") |
| 707 | { |
| 708 | node.first = "example-schema"; |
| 709 | node.second = "leafEnumTypedefRestricted2"; |
| 710 | type = createEnum({"lol", "data"}); |
| 711 | } |
| 712 | |
| 713 | SECTION("pizzaSize") |
| 714 | { |
| 715 | node.first = "example-schema"; |
| 716 | node.second = "pizzaSize"; |
| 717 | |
| 718 | SECTION("bigPizzas disabled") |
| 719 | { |
| 720 | type = createEnum({"small", "medium"}); |
| 721 | } |
| 722 | SECTION("bigPizzas enabled") |
| 723 | { |
| 724 | ys.enableFeature("example-schema", "bigPizzas"); |
| 725 | type = createEnum({"small", "medium", "large"}); |
| 726 | } |
| 727 | } |
| 728 | |
| 729 | SECTION("foodIdentLeaf") |
| 730 | { |
| 731 | node.first = "example-schema"; |
| 732 | node.second = "foodIdentLeaf"; |
| 733 | type = yang::IdentityRef{{{"second-schema", "pineapple"}, |
| 734 | {"example-schema", "food"}, |
| 735 | {"example-schema", "pizza"}, |
| 736 | {"example-schema", "hawaii"}, |
| 737 | {"example-schema", "fruit"}}}; |
| 738 | } |
| 739 | |
| 740 | SECTION("pizzaIdentLeaf") |
| 741 | { |
| 742 | node.first = "example-schema"; |
| 743 | node.second = "pizzaIdentLeaf"; |
| 744 | |
| 745 | type = yang::IdentityRef{{ |
| 746 | {"example-schema", "pizza"}, |
| 747 | {"example-schema", "hawaii"}, |
| 748 | }}; |
| 749 | } |
| 750 | |
| 751 | SECTION("foodDrinkIdentLeaf") |
| 752 | { |
| 753 | node.first = "example-schema"; |
| 754 | node.second = "foodDrinkIdentLeaf"; |
| 755 | |
| 756 | type = yang::IdentityRef{{ |
| 757 | {"example-schema", "food"}, |
| 758 | {"example-schema", "drink"}, |
| 759 | {"example-schema", "fruit"}, |
| 760 | {"example-schema", "hawaii"}, |
| 761 | {"example-schema", "pizza"}, |
| 762 | {"example-schema", "voda"}, |
| 763 | {"second-schema", "pineapple"}, |
| 764 | }}; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 765 | } |
| 766 | |
Václav Kubernát | b6d0275 | 2020-04-03 00:25:10 +0200 | [diff] [blame] | 767 | SECTION("activeNumber") |
| 768 | { |
| 769 | node.first = "example-schema"; |
| 770 | node.second = "activeNumber"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 771 | type.emplace<yang::LeafRef>( |
| 772 | "/example-schema:_list/number", |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 773 | std::make_unique<yang::TypeInfo>(ys.leafType("/example-schema:_list/number")) |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 774 | ); |
Václav Kubernát | b6d0275 | 2020-04-03 00:25:10 +0200 | [diff] [blame] | 775 | } |
| 776 | |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 777 | SECTION("activePort") |
| 778 | { |
| 779 | node.first = "example-schema"; |
| 780 | node.second = "activePort"; |
| 781 | |
| 782 | yang::Enum enums = [&ys]() { |
| 783 | SECTION("weird ports disabled") |
| 784 | { |
| 785 | return createEnum({"utf2", "utf3"}); |
| 786 | } |
| 787 | SECTION("weird ports enabled") |
| 788 | { |
| 789 | ys.enableFeature("example-schema", "weirdPortNames"); |
| 790 | return createEnum({"WEIRD", "utf2", "utf3"}); |
| 791 | } |
| 792 | __builtin_unreachable(); |
| 793 | }(); |
| 794 | |
| 795 | type = yang::Union{{ |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 796 | yang::TypeInfo{createEnum({"wlan0", "wlan1"})}, |
| 797 | yang::TypeInfo{yang::LeafRef{ |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 798 | "/example-schema:portSettings/port", |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 799 | std::make_unique<yang::TypeInfo>(createEnum({"eth0", "eth1", "eth2"})) |
| 800 | }}, |
| 801 | yang::TypeInfo{yang::LeafRef{ |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 802 | "/example-schema:activeMappedPort", |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 803 | std::make_unique<yang::TypeInfo>(yang::LeafRef{ |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 804 | "/example-schema:portMapping/port", |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 805 | std::make_unique<yang::TypeInfo>(enums) |
| 806 | }) |
| 807 | }}, |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 808 | yang::TypeInfo{yang::Empty{}}, |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 809 | }}; |
| 810 | } |
| 811 | |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 812 | REQUIRE(ys.leafType(path, node) == type); |
| 813 | } |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 814 | SECTION("availableNodes") |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 815 | { |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 816 | // TODO: merge "path" and "module" sections and add recursive versions to the path section |
| 817 | SECTION("paths") |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 818 | { |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 819 | std::set<ModuleNodePair> set; |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 820 | |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 821 | using namespace std::string_literals; |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 822 | SECTION("<root>") |
| 823 | { |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 824 | set = {{"example-schema"s, "a"}, {"example-schema"s, "b"}, {"example-schema"s, "leafString"}, |
| 825 | {"example-schema"s, "leafDecimal"}, {"example-schema"s, "leafBool"}, |
| 826 | {"example-schema"s, "leafInt8"}, {"example-schema"s, "leafUint8"}, |
| 827 | {"example-schema"s, "leafInt16"}, {"example-schema"s, "leafUint16"}, |
| 828 | {"example-schema"s, "leafInt32"}, {"example-schema"s, "leafUint32"}, |
| 829 | {"example-schema"s, "leafInt64"}, {"example-schema"s, "leafUint64"}, |
| 830 | {"example-schema"s, "leafEnum"}, {"example-schema"s, "leafEnumTypedef"}, |
| 831 | {"example-schema"s, "leafEnumTypedefRestricted"}, {"example-schema"s, "leafEnumTypedefRestricted2"}, |
| 832 | {"example-schema"s, "foodIdentLeaf"}, {"example-schema"s, "pizzaIdentLeaf"}, {"example-schema"s, "foodDrinkIdentLeaf"}, |
| 833 | {"example-schema"s, "_list"}, {"example-schema"s, "twoKeyList"}, {"second-schema"s, "bla"}, |
| 834 | {"example-schema"s, "carry"}, {"example-schema"s, "zero"}, {"example-schema"s, "direction"}, |
| 835 | {"example-schema"s, "interrupt"}, |
| 836 | {"example-schema"s, "ethernet"}, {"example-schema"s, "loopback"}, |
| 837 | {"example-schema"s, "pizzaSize"}, |
| 838 | {"example-schema"s, "length"}, {"example-schema"s, "wavelength"}, |
| 839 | {"example-schema"s, "duration"}, {"example-schema"s, "another-duration"}, |
| 840 | {"example-schema"s, "activeNumber"}, |
| 841 | {"example-schema"s, "numberOrString"}, |
| 842 | {"example-schema"s, "portSettings"}, |
| 843 | {"example-schema"s, "portMapping"}, |
| 844 | {"example-schema"s, "activeMappedPort"}, |
| 845 | {"example-schema"s, "activePort"}, |
| 846 | {"example-schema"s, "clockSpeed"}, |
| 847 | {"example-schema"s, "deprecatedLeaf"}, |
| 848 | {"example-schema"s, "obsoleteLeaf"}, |
| 849 | {"example-schema"s, "obsoleteLeafWithDeprecatedType"}, |
| 850 | {"example-schema"s, "obsoleteLeafWithObsoleteType"}, |
Václav Kubernát | aaafeae | 2020-05-05 15:41:45 +0200 | [diff] [blame] | 851 | {"example-schema"s, "myRpc"}, |
Václav Kubernát | 82d7463 | 2020-05-11 15:59:53 +0200 | [diff] [blame] | 852 | {"example-schema"s, "systemStats"}, |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 853 | {"example-schema"s, "dummyLeaf"}, |
Václav Kubernát | 82d7463 | 2020-05-11 15:59:53 +0200 | [diff] [blame] | 854 | {"example-schema"s, "subLeaf"}}; |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 855 | } |
| 856 | |
| 857 | SECTION("example-schema:a") |
| 858 | { |
| 859 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a"))); |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 860 | set = { |
| 861 | {boost::none, "a2"}, |
| 862 | {boost::none, "leafa"}, |
| 863 | {"second-schema"s, "augmentedContainer"} |
| 864 | }; |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 865 | } |
| 866 | |
| 867 | SECTION("example-schema:ethernet") |
| 868 | { |
| 869 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("ethernet"))); |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 870 | set = {{boost::none, "ip"}}; |
| 871 | } |
| 872 | |
| 873 | SECTION("second-schema:bla") |
| 874 | { |
| 875 | path.m_nodes.push_back(schemaNode_(module_{"second-schema"}, container_("bla"))); |
| 876 | set = {{boost::none, "bla2"}}; |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 877 | } |
| 878 | |
| 879 | REQUIRE(ys.availableNodes(path, Recursion::NonRecursive) == set); |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 880 | } |
| 881 | |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 882 | SECTION("modules") |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 883 | { |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 884 | std::string module; |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 885 | std::set<ModuleNodePair> expectedNonRecursive; |
| 886 | std::set<ModuleNodePair> expectedRecursive; |
| 887 | using namespace std::string_literals; |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 888 | SECTION("example-schema") |
| 889 | { |
| 890 | module = "example-schema"; |
| 891 | expectedNonRecursive = { |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 892 | {"example-schema"s, "_list"}, |
| 893 | {"example-schema"s, "a"}, |
| 894 | {"example-schema"s, "activeMappedPort"}, |
| 895 | {"example-schema"s, "activeNumber"}, |
| 896 | {"example-schema"s, "activePort"}, |
| 897 | {"example-schema"s, "another-duration"}, |
| 898 | {"example-schema"s, "b"}, |
| 899 | {"example-schema"s, "carry"}, |
| 900 | {"example-schema"s, "clockSpeed"}, |
| 901 | {"example-schema"s, "deprecatedLeaf"}, |
| 902 | {"example-schema"s, "direction"}, |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 903 | {"example-schema"s, "dummyLeaf"}, |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 904 | {"example-schema"s, "duration"}, |
| 905 | {"example-schema"s, "ethernet"}, |
| 906 | {"example-schema"s, "foodDrinkIdentLeaf"}, |
| 907 | {"example-schema"s, "foodIdentLeaf"}, |
| 908 | {"example-schema"s, "interrupt"}, |
| 909 | {"example-schema"s, "leafBool"}, |
| 910 | {"example-schema"s, "leafDecimal"}, |
| 911 | {"example-schema"s, "leafEnum"}, |
| 912 | {"example-schema"s, "leafEnumTypedef"}, |
| 913 | {"example-schema"s, "leafEnumTypedefRestricted"}, |
| 914 | {"example-schema"s, "leafEnumTypedefRestricted2"}, |
| 915 | {"example-schema"s, "leafInt16"}, |
| 916 | {"example-schema"s, "leafInt32"}, |
| 917 | {"example-schema"s, "leafInt64"}, |
| 918 | {"example-schema"s, "leafInt8"}, |
| 919 | {"example-schema"s, "leafString"}, |
| 920 | {"example-schema"s, "leafUint16"}, |
| 921 | {"example-schema"s, "leafUint32"}, |
| 922 | {"example-schema"s, "leafUint64"}, |
| 923 | {"example-schema"s, "leafUint8"}, |
| 924 | {"example-schema"s, "length"}, |
| 925 | {"example-schema"s, "loopback"}, |
Václav Kubernát | aaafeae | 2020-05-05 15:41:45 +0200 | [diff] [blame] | 926 | {"example-schema"s, "myRpc"}, |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 927 | {"example-schema"s, "numberOrString"}, |
| 928 | {"example-schema"s, "obsoleteLeaf"}, |
| 929 | {"example-schema"s, "obsoleteLeafWithDeprecatedType"}, |
| 930 | {"example-schema"s, "obsoleteLeafWithObsoleteType"}, |
| 931 | {"example-schema"s, "pizzaIdentLeaf"}, |
| 932 | {"example-schema"s, "pizzaSize"}, |
| 933 | {"example-schema"s, "portMapping"}, |
| 934 | {"example-schema"s, "portSettings"}, |
| 935 | {"example-schema"s, "systemStats"}, |
| 936 | {"example-schema"s, "twoKeyList"}, |
| 937 | {"example-schema"s, "wavelength"}, |
Václav Kubernát | 82d7463 | 2020-05-11 15:59:53 +0200 | [diff] [blame] | 938 | {"example-schema"s, "zero"}, |
| 939 | {"example-schema"s, "subLeaf"} |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 940 | }; |
| 941 | expectedRecursive = { |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 942 | {boost::none, "/example-schema:_list"}, |
| 943 | {boost::none, "/example-schema:_list/contInList"}, |
| 944 | {boost::none, "/example-schema:_list/number"}, |
| 945 | {boost::none, "/example-schema:a"}, |
| 946 | {boost::none, "/example-schema:a/a2"}, |
| 947 | {boost::none, "/example-schema:a/a2/a3"}, |
| 948 | {boost::none, "/example-schema:a/leafa"}, |
| 949 | {boost::none, "/example-schema:a/second-schema:augmentedContainer"}, |
| 950 | {boost::none, "/example-schema:activeMappedPort"}, |
| 951 | {boost::none, "/example-schema:activeNumber"}, |
| 952 | {boost::none, "/example-schema:activePort"}, |
| 953 | {boost::none, "/example-schema:another-duration"}, |
| 954 | {boost::none, "/example-schema:b"}, |
| 955 | {boost::none, "/example-schema:b/b2"}, |
| 956 | {boost::none, "/example-schema:b/b2/b3"}, |
| 957 | {boost::none, "/example-schema:carry"}, |
| 958 | {boost::none, "/example-schema:clockSpeed"}, |
| 959 | {boost::none, "/example-schema:deprecatedLeaf"}, |
| 960 | {boost::none, "/example-schema:direction"}, |
| 961 | {boost::none, "/example-schema:duration"}, |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 962 | {boost::none, "/example-schema:dummyLeaf"}, |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 963 | {boost::none, "/example-schema:foodDrinkIdentLeaf"}, |
| 964 | {boost::none, "/example-schema:foodIdentLeaf"}, |
| 965 | {boost::none, "/example-schema:interface/caseEthernet/ethernet"}, |
| 966 | {boost::none, "/example-schema:interface/caseEthernet/ethernet/ip"}, |
| 967 | {boost::none, "/example-schema:interface/caseLoopback/loopback"}, |
| 968 | {boost::none, "/example-schema:interface/caseLoopback/loopback/ip"}, |
| 969 | {boost::none, "/example-schema:interrupt"}, |
| 970 | {boost::none, "/example-schema:leafBool"}, |
| 971 | {boost::none, "/example-schema:leafDecimal"}, |
| 972 | {boost::none, "/example-schema:leafEnum"}, |
| 973 | {boost::none, "/example-schema:leafEnumTypedef"}, |
| 974 | {boost::none, "/example-schema:leafEnumTypedefRestricted"}, |
| 975 | {boost::none, "/example-schema:leafEnumTypedefRestricted2"}, |
| 976 | {boost::none, "/example-schema:leafInt16"}, |
| 977 | {boost::none, "/example-schema:leafInt32"}, |
| 978 | {boost::none, "/example-schema:leafInt64"}, |
| 979 | {boost::none, "/example-schema:leafInt8"}, |
| 980 | {boost::none, "/example-schema:leafString"}, |
| 981 | {boost::none, "/example-schema:leafUint16"}, |
| 982 | {boost::none, "/example-schema:leafUint32"}, |
| 983 | {boost::none, "/example-schema:leafUint64"}, |
| 984 | {boost::none, "/example-schema:leafUint8"}, |
| 985 | {boost::none, "/example-schema:length"}, |
Václav Kubernát | aaafeae | 2020-05-05 15:41:45 +0200 | [diff] [blame] | 986 | {boost::none, "/example-schema:myRpc"}, |
| 987 | {boost::none, "/example-schema:myRpc/input"}, |
| 988 | {boost::none, "/example-schema:myRpc/output"}, |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 989 | {boost::none, "/example-schema:numberOrString"}, |
| 990 | {boost::none, "/example-schema:obsoleteLeaf"}, |
| 991 | {boost::none, "/example-schema:obsoleteLeafWithDeprecatedType"}, |
| 992 | {boost::none, "/example-schema:obsoleteLeafWithObsoleteType"}, |
| 993 | {boost::none, "/example-schema:pizzaIdentLeaf"}, |
| 994 | {boost::none, "/example-schema:pizzaSize"}, |
| 995 | {boost::none, "/example-schema:portMapping"}, |
| 996 | {boost::none, "/example-schema:portMapping/port"}, |
| 997 | {boost::none, "/example-schema:portSettings"}, |
| 998 | {boost::none, "/example-schema:portSettings/port"}, |
| 999 | {boost::none, "/example-schema:systemStats"}, |
| 1000 | {boost::none, "/example-schema:systemStats/upTime"}, |
Václav Kubernát | 82d7463 | 2020-05-11 15:59:53 +0200 | [diff] [blame] | 1001 | {boost::none, "/example-schema:subLeaf"}, |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 1002 | {boost::none, "/example-schema:twoKeyList"}, |
| 1003 | {boost::none, "/example-schema:twoKeyList/name"}, |
| 1004 | {boost::none, "/example-schema:twoKeyList/number"}, |
| 1005 | {boost::none, "/example-schema:wavelength"}, |
| 1006 | {boost::none, "/example-schema:zero"} |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 1007 | }; |
| 1008 | } |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 1009 | SECTION("second-schema") |
| 1010 | { |
| 1011 | module = "second-schema"; |
| 1012 | expectedNonRecursive = { |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 1013 | {"second-schema"s, "bla"} |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 1014 | }; |
| 1015 | expectedRecursive = { |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 1016 | {boost::none, "/second-schema:bla"}, |
| 1017 | {boost::none, "/second-schema:bla/bla2"} |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 1018 | }; |
| 1019 | } |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1020 | |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 1021 | REQUIRE(ys.availableNodes(module_{module}, Recursion::NonRecursive) == expectedNonRecursive); |
| 1022 | REQUIRE(ys.availableNodes(module_{module}, Recursion::Recursive) == expectedRecursive); |
Václav Kubernát | 47a3f67 | 2019-11-08 15:42:43 +0100 | [diff] [blame] | 1023 | } |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1024 | } |
Václav Kubernát | 34ee85a | 2020-02-18 17:12:12 +0100 | [diff] [blame] | 1025 | SECTION("nodeType") |
| 1026 | { |
| 1027 | yang::NodeTypes expected; |
| 1028 | SECTION("leafInt32") |
| 1029 | { |
| 1030 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("leafInt32"))); |
| 1031 | expected = yang::NodeTypes::Leaf; |
| 1032 | } |
| 1033 | |
| 1034 | SECTION("a") |
| 1035 | { |
| 1036 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a"))); |
| 1037 | expected = yang::NodeTypes::Container; |
| 1038 | } |
| 1039 | |
| 1040 | SECTION("a/a2/a3") |
| 1041 | { |
| 1042 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a"))); |
| 1043 | path.m_nodes.push_back(schemaNode_(container_("a2"))); |
| 1044 | path.m_nodes.push_back(schemaNode_(container_("a3"))); |
| 1045 | expected = yang::NodeTypes::PresenceContainer; |
| 1046 | } |
| 1047 | |
| 1048 | SECTION("_list") |
| 1049 | { |
| 1050 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, list_("_list"))); |
| 1051 | expected = yang::NodeTypes::List; |
| 1052 | } |
| 1053 | |
Václav Kubernát | 82d7463 | 2020-05-11 15:59:53 +0200 | [diff] [blame] | 1054 | SECTION("subLeaf") |
| 1055 | { |
| 1056 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("subLeaf"))); |
| 1057 | expected = yang::NodeTypes::Leaf; |
| 1058 | } |
| 1059 | |
Václav Kubernát | 34ee85a | 2020-02-18 17:12:12 +0100 | [diff] [blame] | 1060 | REQUIRE(ys.nodeType(pathToSchemaString(path, Prefixes::WhenNeeded)) == expected); |
| 1061 | } |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1062 | |
| 1063 | SECTION("description") |
| 1064 | { |
| 1065 | std::optional<std::string> expected; |
| 1066 | SECTION("leafInt32") |
| 1067 | { |
| 1068 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("leafInt32"))); |
| 1069 | expected = "A 32-bit integer leaf."; |
| 1070 | } |
| 1071 | |
| 1072 | SECTION("leafString") |
| 1073 | { |
| 1074 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("leafString"))); |
| 1075 | } |
| 1076 | |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 1077 | SECTION("numberOrString") |
| 1078 | { |
| 1079 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("numberOrString"))); |
| 1080 | expected = "Can be an int32 or a string."; |
| 1081 | } |
| 1082 | |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1083 | REQUIRE(ys.description(pathToSchemaString(path, Prefixes::WhenNeeded)) == expected); |
| 1084 | } |
| 1085 | |
Václav Kubernát | a1c4c9e | 2020-04-22 00:37:52 +0200 | [diff] [blame] | 1086 | SECTION("status") |
| 1087 | { |
| 1088 | REQUIRE(ys.status("/example-schema:leafUint64") == yang::Status::Current); |
| 1089 | REQUIRE(ys.status("/example-schema:obsoleteLeaf") == yang::Status::Obsolete); |
| 1090 | REQUIRE(ys.status("/example-schema:deprecatedLeaf") == yang::Status::Deprecated); |
| 1091 | REQUIRE(ys.status("/example-schema:obsoleteLeafWithDeprecatedType") == yang::Status::Obsolete); |
| 1092 | REQUIRE(ys.status("/example-schema:obsoleteLeafWithObsoleteType") == yang::Status::Obsolete); |
| 1093 | } |
| 1094 | |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1095 | SECTION("units") |
| 1096 | { |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 1097 | yang::LeafDataType expectedType; |
| 1098 | std::optional<std::string> expectedUnits; |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1099 | SECTION("length") |
| 1100 | { |
| 1101 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("length"))); |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 1102 | expectedType.emplace<yang::Int32>(); |
| 1103 | expectedUnits = "m"; |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1104 | } |
| 1105 | |
| 1106 | SECTION("wavelength") |
| 1107 | { |
| 1108 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("wavelength"))); |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 1109 | expectedType.emplace<yang::Decimal>(); |
| 1110 | expectedUnits = "nm"; |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1111 | } |
| 1112 | |
| 1113 | SECTION("leafInt32") |
| 1114 | { |
| 1115 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("leafInt32"))); |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 1116 | expectedType.emplace<yang::Int32>(); |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1117 | } |
| 1118 | |
| 1119 | SECTION("duration") |
| 1120 | { |
| 1121 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("duration"))); |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 1122 | expectedType.emplace<yang::Int32>(); |
| 1123 | expectedUnits = "s"; |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1124 | } |
| 1125 | |
| 1126 | SECTION("another-duration") |
| 1127 | { |
| 1128 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("another-duration"))); |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 1129 | expectedType.emplace<yang::Int32>(); |
| 1130 | expectedUnits = "vt"; |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1131 | } |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 1132 | REQUIRE(ys.leafType(pathToSchemaString(path, Prefixes::WhenNeeded)) == yang::TypeInfo{expectedType, expectedUnits}); |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1133 | } |
| 1134 | |
| 1135 | SECTION("nodeType") |
| 1136 | { |
| 1137 | yang::NodeTypes expected; |
| 1138 | SECTION("leafInt32") |
| 1139 | { |
| 1140 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("leafInt32"))); |
| 1141 | expected = yang::NodeTypes::Leaf; |
| 1142 | } |
| 1143 | |
| 1144 | SECTION("a") |
| 1145 | { |
| 1146 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a"))); |
| 1147 | expected = yang::NodeTypes::Container; |
| 1148 | } |
| 1149 | |
| 1150 | SECTION("a/a2/a3") |
| 1151 | { |
| 1152 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a"))); |
| 1153 | path.m_nodes.push_back(schemaNode_(container_("a2"))); |
| 1154 | path.m_nodes.push_back(schemaNode_(container_("a3"))); |
| 1155 | expected = yang::NodeTypes::PresenceContainer; |
| 1156 | } |
| 1157 | |
| 1158 | SECTION("_list") |
| 1159 | { |
| 1160 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, list_("_list"))); |
| 1161 | expected = yang::NodeTypes::List; |
| 1162 | } |
| 1163 | |
| 1164 | REQUIRE(ys.nodeType(pathToSchemaString(path, Prefixes::WhenNeeded)) == expected); |
| 1165 | } |
Václav Kubernát | bd5e3c2 | 2020-02-19 15:22:00 +0100 | [diff] [blame] | 1166 | |
| 1167 | SECTION("leafrefPath") |
| 1168 | { |
| 1169 | REQUIRE(ys.leafrefPath("/example-schema:activeNumber") == "/example-schema:_list/number"); |
| 1170 | } |
Václav Kubernát | 0599e9f | 2020-04-21 09:51:33 +0200 | [diff] [blame] | 1171 | |
| 1172 | SECTION("isConfig") |
| 1173 | { |
| 1174 | REQUIRE(ys.isConfig("/example-schema:leafInt32")); |
| 1175 | REQUIRE_FALSE(ys.isConfig("/example-schema:clockSpeed")); |
| 1176 | REQUIRE_FALSE(ys.isConfig("/example-schema:systemStats")); |
| 1177 | REQUIRE_FALSE(ys.isConfig("/example-schema:systemStats/upTime")); |
| 1178 | } |
Václav Kubernát | bd0d5c8 | 2020-04-21 10:22:03 +0200 | [diff] [blame] | 1179 | |
Václav Kubernát | b1a75c6 | 2020-04-21 15:20:16 +0200 | [diff] [blame] | 1180 | SECTION("defaultValue") |
| 1181 | { |
| 1182 | REQUIRE(ys.defaultValue("/example-schema:leafUint64") == "9001"); |
| 1183 | REQUIRE(ys.defaultValue("/example-schema:leafEnumTypedefRestricted") == "data"); |
| 1184 | REQUIRE(ys.defaultValue("/example-schema:leafInt32") == std::nullopt); |
| 1185 | } |
| 1186 | |
Václav Kubernát | 76ba4ec | 2020-05-18 13:26:56 +0200 | [diff] [blame^] | 1187 | SECTION("leafTypeName") |
| 1188 | { |
| 1189 | REQUIRE(ys.leafTypeName("/example-schema:leafEnumTypedefRestricted") == "enumTypedef"); |
| 1190 | REQUIRE(ys.leafTypeName("/example-schema:leafInt32") == std::nullopt); |
| 1191 | } |
| 1192 | |
Václav Kubernát | bd0d5c8 | 2020-04-21 10:22:03 +0200 | [diff] [blame] | 1193 | SECTION("moduleNodes") |
| 1194 | { |
Václav Kubernát | bd0d5c8 | 2020-04-21 10:22:03 +0200 | [diff] [blame] | 1195 | } |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1196 | } |
| 1197 | |
| 1198 | SECTION("negative") |
| 1199 | { |
| 1200 | SECTION("nonexistent nodes") |
| 1201 | { |
| 1202 | SECTION("example-schema:coze") |
| 1203 | { |
| 1204 | node.first = "example-schema"; |
| 1205 | node.second = "coze"; |
| 1206 | } |
| 1207 | |
| 1208 | SECTION("example-schema:a/nevim") |
| 1209 | { |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 1210 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a"))); |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1211 | node.second = "nevim"; |
| 1212 | } |
| 1213 | |
| 1214 | SECTION("modul:a/nevim") |
| 1215 | { |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 1216 | path.m_nodes.push_back(schemaNode_(module_{"modul"}, container_("a"))); |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1217 | node.second = "nevim"; |
| 1218 | } |
| 1219 | |
| 1220 | REQUIRE(!ys.isPresenceContainer(path, node)); |
| 1221 | REQUIRE(!ys.isList(path, node)); |
| 1222 | REQUIRE(!ys.isLeaf(path, node)); |
| 1223 | REQUIRE(!ys.isContainer(path, node)); |
| 1224 | } |
| 1225 | |
| 1226 | SECTION("\"is\" methods return false for existing nodes for different nodetypes") |
| 1227 | { |
| 1228 | SECTION("example-schema:a") |
| 1229 | { |
| 1230 | node.first = "example-schema"; |
| 1231 | node.second = "a"; |
| 1232 | } |
| 1233 | |
| 1234 | SECTION("example-schema:a/a2") |
| 1235 | { |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 1236 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a"))); |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1237 | node.second = "a2"; |
| 1238 | } |
| 1239 | |
| 1240 | REQUIRE(!ys.isPresenceContainer(path, node)); |
| 1241 | REQUIRE(!ys.isList(path, node)); |
| 1242 | REQUIRE(!ys.isLeaf(path, node)); |
| 1243 | } |
| 1244 | |
| 1245 | SECTION("nodetype-specific methods called with different nodetypes") |
| 1246 | { |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 1247 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a"))); |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1248 | node.second = "a2"; |
| 1249 | |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1250 | REQUIRE(!ys.listHasKey(path, node, "chacha")); |
| 1251 | } |
| 1252 | |
| 1253 | SECTION("nonexistent module") |
| 1254 | { |
Václav Kubernát | 75877de | 2019-11-20 17:43:02 +0100 | [diff] [blame] | 1255 | REQUIRE(!ys.isModule("notAModule")); |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1256 | } |
Václav Kubernát | eeb3884 | 2019-03-20 19:46:05 +0100 | [diff] [blame] | 1257 | |
Václav Kubernát | 7d82da7 | 2019-04-11 15:16:38 +0200 | [diff] [blame] | 1258 | SECTION("grouping is not a node") |
| 1259 | { |
| 1260 | SECTION("example-schema:arithmeticFlags") |
| 1261 | { |
| 1262 | node.first = "example-schema"; |
| 1263 | node.second = "arithmeticFlags"; |
| 1264 | } |
| 1265 | |
| 1266 | SECTION("example-schema:flags") |
| 1267 | { |
| 1268 | node.first = "example-schema"; |
| 1269 | node.second = "startAndStop"; |
| 1270 | } |
| 1271 | |
| 1272 | REQUIRE(!ys.isPresenceContainer(path, node)); |
| 1273 | REQUIRE(!ys.isList(path, node)); |
| 1274 | REQUIRE(!ys.isLeaf(path, node)); |
| 1275 | REQUIRE(!ys.isContainer(path, node)); |
| 1276 | } |
Václav Kubernát | 280df4a | 2019-11-01 14:46:34 +0100 | [diff] [blame] | 1277 | |
| 1278 | SECTION("choice is not a node") |
| 1279 | { |
| 1280 | SECTION("example-schema:interface") |
| 1281 | { |
| 1282 | node.first = "example-schema"; |
| 1283 | node.second = "interface"; |
| 1284 | } |
| 1285 | |
| 1286 | REQUIRE(!ys.isPresenceContainer(path, node)); |
| 1287 | REQUIRE(!ys.isList(path, node)); |
| 1288 | REQUIRE(!ys.isLeaf(path, node)); |
| 1289 | REQUIRE(!ys.isContainer(path, node)); |
| 1290 | } |
| 1291 | |
| 1292 | SECTION("case is not a node") |
| 1293 | { |
| 1294 | SECTION("example-schema:caseLoopback") |
| 1295 | { |
| 1296 | node.first = "example-schema"; |
| 1297 | node.second = "caseLoopback"; |
| 1298 | } |
| 1299 | |
| 1300 | SECTION("example-schema:caseEthernet") |
| 1301 | { |
| 1302 | node.first = "example-schema"; |
| 1303 | node.second = "caseEthernet"; |
| 1304 | } |
| 1305 | |
| 1306 | REQUIRE(!ys.isPresenceContainer(path, node)); |
| 1307 | REQUIRE(!ys.isList(path, node)); |
| 1308 | REQUIRE(!ys.isLeaf(path, node)); |
| 1309 | REQUIRE(!ys.isContainer(path, node)); |
| 1310 | } |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1311 | } |
| 1312 | } |