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 | 5b8a8f3 | 2020-05-20 00:57:22 +0200 | [diff] [blame] | 422 | leaf-list addresses { |
| 423 | type string; |
| 424 | } |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 425 | })"; |
| 426 | |
Václav Kubernát | 47a3f67 | 2019-11-08 15:42:43 +0100 | [diff] [blame] | 427 | namespace std { |
| 428 | std::ostream& operator<<(std::ostream& s, const std::set<std::string> set) |
| 429 | { |
| 430 | s << std::endl << "{"; |
| 431 | std::copy(set.begin(), set.end(), std::experimental::make_ostream_joiner(s, ", ")); |
| 432 | s << "}" << std::endl; |
| 433 | return s; |
| 434 | } |
| 435 | } |
| 436 | |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 437 | TEST_CASE("yangschema") |
| 438 | { |
Václav Kubernát | 82d7463 | 2020-05-11 15:59:53 +0200 | [diff] [blame] | 439 | using namespace std::string_literals; |
Václav Kubernát | 4f77a25 | 2019-02-19 16:51:30 +0100 | [diff] [blame] | 440 | using namespace std::string_view_literals; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 441 | YangSchema ys; |
Václav Kubernát | 82d7463 | 2020-05-11 15:59:53 +0200 | [diff] [blame] | 442 | ys.registerModuleCallback([]([[maybe_unused]] auto modName, auto, auto subModule, auto) { |
| 443 | if (modName != "example-schema"sv) { |
| 444 | throw std::logic_error("unrecognized module "s + modName); |
| 445 | } |
| 446 | if (subModule == nullptr) { |
| 447 | return example_schema; |
| 448 | } |
| 449 | if (subModule == "sub-module"sv) { |
| 450 | return included_submodule; |
| 451 | } |
| 452 | |
| 453 | throw std::logic_error("unrecognized submodule "s + subModule); |
Václav Kubernát | 4f77a25 | 2019-02-19 16:51:30 +0100 | [diff] [blame] | 454 | }); |
| 455 | ys.addSchemaString(second_schema); |
| 456 | |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 457 | schemaPath_ path{Scope::Absolute, {}}; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 458 | ModuleNodePair node; |
| 459 | |
| 460 | SECTION("positive") |
| 461 | { |
| 462 | SECTION("isContainer") |
| 463 | { |
| 464 | SECTION("example-schema:a") |
| 465 | { |
| 466 | node.first = "example-schema"; |
| 467 | node.second = "a"; |
| 468 | } |
| 469 | |
| 470 | SECTION("example-schema:a/a2") |
| 471 | { |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 472 | 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] | 473 | node.second = "a2"; |
| 474 | } |
| 475 | |
Václav Kubernát | 280df4a | 2019-11-01 14:46:34 +0100 | [diff] [blame] | 476 | SECTION("example-schema:ethernet") |
| 477 | { |
| 478 | node.first = "example-schema"; |
| 479 | node.second = "ethernet"; |
| 480 | } |
| 481 | |
| 482 | SECTION("example-schema:loopback") |
| 483 | { |
| 484 | node.first = "example-schema"; |
| 485 | node.second = "loopback"; |
| 486 | } |
| 487 | |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 488 | REQUIRE(ys.isContainer(path, node)); |
| 489 | } |
| 490 | SECTION("isLeaf") |
| 491 | { |
| 492 | SECTION("example-schema:leafString") |
| 493 | { |
| 494 | node.first = "example-schema"; |
| 495 | node.second = "leafString"; |
| 496 | } |
| 497 | |
| 498 | SECTION("example-schema:a/leafa") |
| 499 | { |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 500 | 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] | 501 | node.first = "example-schema"; |
| 502 | node.second = "leafa"; |
| 503 | } |
| 504 | |
Václav Kubernát | 7d82da7 | 2019-04-11 15:16:38 +0200 | [diff] [blame] | 505 | SECTION("example-schema:carry") |
| 506 | { |
| 507 | node.first = "example-schema"; |
| 508 | node.second = "carry"; |
| 509 | } |
| 510 | |
| 511 | SECTION("example-schema:zero") |
| 512 | { |
| 513 | node.first = "example-schema"; |
| 514 | node.second = "zero"; |
| 515 | } |
| 516 | |
| 517 | SECTION("example-schema:direction") |
| 518 | { |
| 519 | node.first = "example-schema"; |
| 520 | node.second = "direction"; |
| 521 | } |
| 522 | |
| 523 | SECTION("example-schema:interrupt") |
| 524 | { |
| 525 | node.first = "example-schema"; |
| 526 | node.second = "interrupt"; |
| 527 | } |
| 528 | |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 529 | REQUIRE(ys.isLeaf(path, node)); |
| 530 | } |
| 531 | SECTION("isModule") |
| 532 | { |
Václav Kubernát | 75877de | 2019-11-20 17:43:02 +0100 | [diff] [blame] | 533 | REQUIRE(ys.isModule("example-schema")); |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 534 | } |
| 535 | SECTION("isList") |
| 536 | { |
| 537 | SECTION("example-schema:_list") |
| 538 | { |
| 539 | node.first = "example-schema"; |
| 540 | node.second = "_list"; |
| 541 | } |
| 542 | |
| 543 | SECTION("example-schema:twoKeyList") |
| 544 | { |
| 545 | node.first = "example-schema"; |
| 546 | node.second = "twoKeyList"; |
| 547 | } |
| 548 | |
| 549 | REQUIRE(ys.isList(path, node)); |
| 550 | } |
| 551 | SECTION("isPresenceContainer") |
| 552 | { |
| 553 | SECTION("example-schema:a/a2/a3") |
| 554 | { |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 555 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a"))); |
| 556 | 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] | 557 | node.second = "a3"; |
| 558 | } |
| 559 | |
| 560 | REQUIRE(ys.isPresenceContainer(path, node)); |
| 561 | } |
Václav Kubernát | eeb3884 | 2019-03-20 19:46:05 +0100 | [diff] [blame] | 562 | |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 563 | SECTION("listHasKey") |
| 564 | { |
| 565 | std::string key; |
| 566 | |
| 567 | SECTION("_list") |
| 568 | { |
| 569 | node.first = "example-schema"; |
| 570 | node.second = "_list"; |
| 571 | SECTION("number") |
| 572 | key = "number"; |
| 573 | } |
| 574 | |
| 575 | SECTION("twoKeyList") |
| 576 | { |
| 577 | node.first = "example-schema"; |
| 578 | node.second = "twoKeyList"; |
| 579 | SECTION("number") |
| 580 | key = "number"; |
| 581 | SECTION("name") |
| 582 | key = "name"; |
| 583 | } |
| 584 | |
| 585 | REQUIRE(ys.listHasKey(path, node, key)); |
| 586 | } |
| 587 | SECTION("listKeys") |
| 588 | { |
| 589 | std::set<std::string> set; |
| 590 | |
| 591 | SECTION("_list") |
| 592 | { |
| 593 | set = {"number"}; |
| 594 | node.first = "example-schema"; |
| 595 | node.second = "_list"; |
| 596 | } |
| 597 | |
| 598 | SECTION("twoKeyList") |
| 599 | { |
| 600 | set = {"number", "name"}; |
| 601 | node.first = "example-schema"; |
| 602 | node.second = "twoKeyList"; |
| 603 | } |
| 604 | |
| 605 | REQUIRE(ys.listKeys(path, node) == set); |
| 606 | } |
| 607 | SECTION("leafType") |
| 608 | { |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 609 | yang::LeafDataType type; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 610 | |
| 611 | SECTION("leafString") |
| 612 | { |
| 613 | node.first = "example-schema"; |
| 614 | node.second = "leafString"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 615 | type = yang::String{}; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | SECTION("leafDecimal") |
| 619 | { |
| 620 | node.first = "example-schema"; |
| 621 | node.second = "leafDecimal"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 622 | type = yang::Decimal{}; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | SECTION("leafBool") |
| 626 | { |
| 627 | node.first = "example-schema"; |
| 628 | node.second = "leafBool"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 629 | type = yang::Bool{}; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 630 | } |
| 631 | |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 632 | SECTION("leafInt8") |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 633 | { |
| 634 | node.first = "example-schema"; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 635 | node.second = "leafInt8"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 636 | type = yang::Int8{}; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 637 | } |
| 638 | |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 639 | SECTION("leafUint8") |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 640 | { |
| 641 | node.first = "example-schema"; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 642 | node.second = "leafUint8"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 643 | type = yang::Uint8{}; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 644 | } |
| 645 | |
Václav Kubernát | b6d0275 | 2020-04-03 00:25:10 +0200 | [diff] [blame] | 646 | SECTION("leafInt16") |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 647 | { |
| 648 | node.first = "example-schema"; |
| 649 | node.second = "leafInt16"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 650 | type = yang::Int16{}; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | SECTION("leafUint16") |
| 654 | { |
| 655 | node.first = "example-schema"; |
| 656 | node.second = "leafUint16"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 657 | type = yang::Uint16{}; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 658 | } |
| 659 | |
| 660 | SECTION("leafInt32") |
| 661 | { |
| 662 | node.first = "example-schema"; |
| 663 | node.second = "leafInt32"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 664 | type = yang::Int32{}; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | SECTION("leafUint32") |
| 668 | { |
| 669 | node.first = "example-schema"; |
| 670 | node.second = "leafUint32"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 671 | type = yang::Uint32{}; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | SECTION("leafInt64") |
| 675 | { |
| 676 | node.first = "example-schema"; |
| 677 | node.second = "leafInt64"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 678 | type = yang::Int64{}; |
Ivona Oboňová | 88c78ca | 2019-07-02 18:40:07 +0200 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | SECTION("leafUint64") |
| 682 | { |
| 683 | node.first = "example-schema"; |
| 684 | node.second = "leafUint64"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 685 | type = yang::Uint64{}; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 686 | } |
| 687 | |
| 688 | SECTION("leafEnum") |
| 689 | { |
| 690 | node.first = "example-schema"; |
| 691 | node.second = "leafEnum"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 692 | type = createEnum({"lol", "data", "coze"}); |
| 693 | } |
| 694 | |
| 695 | SECTION("leafEnumTypedef") |
| 696 | { |
| 697 | node.first = "example-schema"; |
| 698 | node.second = "leafEnumTypedef"; |
| 699 | type = createEnum({"lol", "data", "coze"}); |
| 700 | } |
| 701 | |
| 702 | SECTION("leafEnumTypedefRestricted") |
| 703 | { |
| 704 | node.first = "example-schema"; |
| 705 | node.second = "leafEnumTypedefRestricted"; |
| 706 | type = createEnum({"data", "coze"}); |
| 707 | } |
| 708 | |
| 709 | SECTION("leafEnumTypedefRestricted2") |
| 710 | { |
| 711 | node.first = "example-schema"; |
| 712 | node.second = "leafEnumTypedefRestricted2"; |
| 713 | type = createEnum({"lol", "data"}); |
| 714 | } |
| 715 | |
| 716 | SECTION("pizzaSize") |
| 717 | { |
| 718 | node.first = "example-schema"; |
| 719 | node.second = "pizzaSize"; |
| 720 | |
| 721 | SECTION("bigPizzas disabled") |
| 722 | { |
| 723 | type = createEnum({"small", "medium"}); |
| 724 | } |
| 725 | SECTION("bigPizzas enabled") |
| 726 | { |
| 727 | ys.enableFeature("example-schema", "bigPizzas"); |
| 728 | type = createEnum({"small", "medium", "large"}); |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | SECTION("foodIdentLeaf") |
| 733 | { |
| 734 | node.first = "example-schema"; |
| 735 | node.second = "foodIdentLeaf"; |
| 736 | type = yang::IdentityRef{{{"second-schema", "pineapple"}, |
| 737 | {"example-schema", "food"}, |
| 738 | {"example-schema", "pizza"}, |
| 739 | {"example-schema", "hawaii"}, |
| 740 | {"example-schema", "fruit"}}}; |
| 741 | } |
| 742 | |
| 743 | SECTION("pizzaIdentLeaf") |
| 744 | { |
| 745 | node.first = "example-schema"; |
| 746 | node.second = "pizzaIdentLeaf"; |
| 747 | |
| 748 | type = yang::IdentityRef{{ |
| 749 | {"example-schema", "pizza"}, |
| 750 | {"example-schema", "hawaii"}, |
| 751 | }}; |
| 752 | } |
| 753 | |
| 754 | SECTION("foodDrinkIdentLeaf") |
| 755 | { |
| 756 | node.first = "example-schema"; |
| 757 | node.second = "foodDrinkIdentLeaf"; |
| 758 | |
| 759 | type = yang::IdentityRef{{ |
| 760 | {"example-schema", "food"}, |
| 761 | {"example-schema", "drink"}, |
| 762 | {"example-schema", "fruit"}, |
| 763 | {"example-schema", "hawaii"}, |
| 764 | {"example-schema", "pizza"}, |
| 765 | {"example-schema", "voda"}, |
| 766 | {"second-schema", "pineapple"}, |
| 767 | }}; |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 768 | } |
| 769 | |
Václav Kubernát | b6d0275 | 2020-04-03 00:25:10 +0200 | [diff] [blame] | 770 | SECTION("activeNumber") |
| 771 | { |
| 772 | node.first = "example-schema"; |
| 773 | node.second = "activeNumber"; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 774 | type.emplace<yang::LeafRef>( |
| 775 | "/example-schema:_list/number", |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 776 | 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] | 777 | ); |
Václav Kubernát | b6d0275 | 2020-04-03 00:25:10 +0200 | [diff] [blame] | 778 | } |
| 779 | |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 780 | SECTION("activePort") |
| 781 | { |
| 782 | node.first = "example-schema"; |
| 783 | node.second = "activePort"; |
| 784 | |
| 785 | yang::Enum enums = [&ys]() { |
| 786 | SECTION("weird ports disabled") |
| 787 | { |
| 788 | return createEnum({"utf2", "utf3"}); |
| 789 | } |
| 790 | SECTION("weird ports enabled") |
| 791 | { |
| 792 | ys.enableFeature("example-schema", "weirdPortNames"); |
| 793 | return createEnum({"WEIRD", "utf2", "utf3"}); |
| 794 | } |
| 795 | __builtin_unreachable(); |
| 796 | }(); |
| 797 | |
| 798 | type = yang::Union{{ |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 799 | yang::TypeInfo{createEnum({"wlan0", "wlan1"})}, |
| 800 | yang::TypeInfo{yang::LeafRef{ |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 801 | "/example-schema:portSettings/port", |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 802 | std::make_unique<yang::TypeInfo>(createEnum({"eth0", "eth1", "eth2"})) |
| 803 | }}, |
| 804 | yang::TypeInfo{yang::LeafRef{ |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 805 | "/example-schema:activeMappedPort", |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 806 | std::make_unique<yang::TypeInfo>(yang::LeafRef{ |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 807 | "/example-schema:portMapping/port", |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 808 | std::make_unique<yang::TypeInfo>(enums) |
| 809 | }) |
| 810 | }}, |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 811 | yang::TypeInfo{yang::Empty{}}, |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 812 | }}; |
| 813 | } |
| 814 | |
Václav Kubernát | 5b8a8f3 | 2020-05-20 00:57:22 +0200 | [diff] [blame] | 815 | SECTION("addresses") |
| 816 | { |
| 817 | node.first = "example-schema"; |
| 818 | node.second = "addresses"; |
| 819 | type.emplace<yang::String>(); |
| 820 | } |
| 821 | |
| 822 | |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 823 | REQUIRE(ys.leafType(path, node) == type); |
| 824 | } |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 825 | SECTION("availableNodes") |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 826 | { |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 827 | // TODO: merge "path" and "module" sections and add recursive versions to the path section |
| 828 | SECTION("paths") |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 829 | { |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 830 | std::set<ModuleNodePair> set; |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 831 | |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 832 | using namespace std::string_literals; |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 833 | SECTION("<root>") |
| 834 | { |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 835 | set = {{"example-schema"s, "a"}, {"example-schema"s, "b"}, {"example-schema"s, "leafString"}, |
| 836 | {"example-schema"s, "leafDecimal"}, {"example-schema"s, "leafBool"}, |
| 837 | {"example-schema"s, "leafInt8"}, {"example-schema"s, "leafUint8"}, |
| 838 | {"example-schema"s, "leafInt16"}, {"example-schema"s, "leafUint16"}, |
| 839 | {"example-schema"s, "leafInt32"}, {"example-schema"s, "leafUint32"}, |
| 840 | {"example-schema"s, "leafInt64"}, {"example-schema"s, "leafUint64"}, |
| 841 | {"example-schema"s, "leafEnum"}, {"example-schema"s, "leafEnumTypedef"}, |
| 842 | {"example-schema"s, "leafEnumTypedefRestricted"}, {"example-schema"s, "leafEnumTypedefRestricted2"}, |
| 843 | {"example-schema"s, "foodIdentLeaf"}, {"example-schema"s, "pizzaIdentLeaf"}, {"example-schema"s, "foodDrinkIdentLeaf"}, |
| 844 | {"example-schema"s, "_list"}, {"example-schema"s, "twoKeyList"}, {"second-schema"s, "bla"}, |
| 845 | {"example-schema"s, "carry"}, {"example-schema"s, "zero"}, {"example-schema"s, "direction"}, |
| 846 | {"example-schema"s, "interrupt"}, |
| 847 | {"example-schema"s, "ethernet"}, {"example-schema"s, "loopback"}, |
| 848 | {"example-schema"s, "pizzaSize"}, |
| 849 | {"example-schema"s, "length"}, {"example-schema"s, "wavelength"}, |
| 850 | {"example-schema"s, "duration"}, {"example-schema"s, "another-duration"}, |
| 851 | {"example-schema"s, "activeNumber"}, |
| 852 | {"example-schema"s, "numberOrString"}, |
| 853 | {"example-schema"s, "portSettings"}, |
| 854 | {"example-schema"s, "portMapping"}, |
| 855 | {"example-schema"s, "activeMappedPort"}, |
| 856 | {"example-schema"s, "activePort"}, |
| 857 | {"example-schema"s, "clockSpeed"}, |
| 858 | {"example-schema"s, "deprecatedLeaf"}, |
| 859 | {"example-schema"s, "obsoleteLeaf"}, |
| 860 | {"example-schema"s, "obsoleteLeafWithDeprecatedType"}, |
| 861 | {"example-schema"s, "obsoleteLeafWithObsoleteType"}, |
Václav Kubernát | aaafeae | 2020-05-05 15:41:45 +0200 | [diff] [blame] | 862 | {"example-schema"s, "myRpc"}, |
Václav Kubernát | 82d7463 | 2020-05-11 15:59:53 +0200 | [diff] [blame] | 863 | {"example-schema"s, "systemStats"}, |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 864 | {"example-schema"s, "dummyLeaf"}, |
Václav Kubernát | 5b8a8f3 | 2020-05-20 00:57:22 +0200 | [diff] [blame] | 865 | {"example-schema"s, "addresses"}, |
Václav Kubernát | 82d7463 | 2020-05-11 15:59:53 +0200 | [diff] [blame] | 866 | {"example-schema"s, "subLeaf"}}; |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 867 | } |
| 868 | |
| 869 | SECTION("example-schema:a") |
| 870 | { |
| 871 | 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] | 872 | set = { |
| 873 | {boost::none, "a2"}, |
| 874 | {boost::none, "leafa"}, |
| 875 | {"second-schema"s, "augmentedContainer"} |
| 876 | }; |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 877 | } |
| 878 | |
| 879 | SECTION("example-schema:ethernet") |
| 880 | { |
| 881 | 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] | 882 | set = {{boost::none, "ip"}}; |
| 883 | } |
| 884 | |
| 885 | SECTION("second-schema:bla") |
| 886 | { |
| 887 | path.m_nodes.push_back(schemaNode_(module_{"second-schema"}, container_("bla"))); |
| 888 | set = {{boost::none, "bla2"}}; |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 889 | } |
| 890 | |
| 891 | REQUIRE(ys.availableNodes(path, Recursion::NonRecursive) == set); |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 892 | } |
| 893 | |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 894 | SECTION("modules") |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 895 | { |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 896 | std::string module; |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 897 | std::set<ModuleNodePair> expectedNonRecursive; |
| 898 | std::set<ModuleNodePair> expectedRecursive; |
| 899 | using namespace std::string_literals; |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 900 | SECTION("example-schema") |
| 901 | { |
| 902 | module = "example-schema"; |
| 903 | expectedNonRecursive = { |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 904 | {"example-schema"s, "_list"}, |
| 905 | {"example-schema"s, "a"}, |
| 906 | {"example-schema"s, "activeMappedPort"}, |
| 907 | {"example-schema"s, "activeNumber"}, |
| 908 | {"example-schema"s, "activePort"}, |
Václav Kubernát | 5b8a8f3 | 2020-05-20 00:57:22 +0200 | [diff] [blame] | 909 | {"example-schema"s, "addresses"}, |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 910 | {"example-schema"s, "another-duration"}, |
| 911 | {"example-schema"s, "b"}, |
| 912 | {"example-schema"s, "carry"}, |
| 913 | {"example-schema"s, "clockSpeed"}, |
| 914 | {"example-schema"s, "deprecatedLeaf"}, |
| 915 | {"example-schema"s, "direction"}, |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 916 | {"example-schema"s, "dummyLeaf"}, |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 917 | {"example-schema"s, "duration"}, |
| 918 | {"example-schema"s, "ethernet"}, |
| 919 | {"example-schema"s, "foodDrinkIdentLeaf"}, |
| 920 | {"example-schema"s, "foodIdentLeaf"}, |
| 921 | {"example-schema"s, "interrupt"}, |
| 922 | {"example-schema"s, "leafBool"}, |
| 923 | {"example-schema"s, "leafDecimal"}, |
| 924 | {"example-schema"s, "leafEnum"}, |
| 925 | {"example-schema"s, "leafEnumTypedef"}, |
| 926 | {"example-schema"s, "leafEnumTypedefRestricted"}, |
| 927 | {"example-schema"s, "leafEnumTypedefRestricted2"}, |
| 928 | {"example-schema"s, "leafInt16"}, |
| 929 | {"example-schema"s, "leafInt32"}, |
| 930 | {"example-schema"s, "leafInt64"}, |
| 931 | {"example-schema"s, "leafInt8"}, |
| 932 | {"example-schema"s, "leafString"}, |
| 933 | {"example-schema"s, "leafUint16"}, |
| 934 | {"example-schema"s, "leafUint32"}, |
| 935 | {"example-schema"s, "leafUint64"}, |
| 936 | {"example-schema"s, "leafUint8"}, |
| 937 | {"example-schema"s, "length"}, |
| 938 | {"example-schema"s, "loopback"}, |
Václav Kubernát | aaafeae | 2020-05-05 15:41:45 +0200 | [diff] [blame] | 939 | {"example-schema"s, "myRpc"}, |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 940 | {"example-schema"s, "numberOrString"}, |
| 941 | {"example-schema"s, "obsoleteLeaf"}, |
| 942 | {"example-schema"s, "obsoleteLeafWithDeprecatedType"}, |
| 943 | {"example-schema"s, "obsoleteLeafWithObsoleteType"}, |
| 944 | {"example-schema"s, "pizzaIdentLeaf"}, |
| 945 | {"example-schema"s, "pizzaSize"}, |
| 946 | {"example-schema"s, "portMapping"}, |
| 947 | {"example-schema"s, "portSettings"}, |
| 948 | {"example-schema"s, "systemStats"}, |
| 949 | {"example-schema"s, "twoKeyList"}, |
| 950 | {"example-schema"s, "wavelength"}, |
Václav Kubernát | 82d7463 | 2020-05-11 15:59:53 +0200 | [diff] [blame] | 951 | {"example-schema"s, "zero"}, |
| 952 | {"example-schema"s, "subLeaf"} |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 953 | }; |
| 954 | expectedRecursive = { |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 955 | {boost::none, "/example-schema:_list"}, |
| 956 | {boost::none, "/example-schema:_list/contInList"}, |
| 957 | {boost::none, "/example-schema:_list/number"}, |
| 958 | {boost::none, "/example-schema:a"}, |
Václav Kubernát | 5b8a8f3 | 2020-05-20 00:57:22 +0200 | [diff] [blame] | 959 | {boost::none, "/example-schema:addresses"}, |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 960 | {boost::none, "/example-schema:a/a2"}, |
| 961 | {boost::none, "/example-schema:a/a2/a3"}, |
| 962 | {boost::none, "/example-schema:a/leafa"}, |
| 963 | {boost::none, "/example-schema:a/second-schema:augmentedContainer"}, |
| 964 | {boost::none, "/example-schema:activeMappedPort"}, |
| 965 | {boost::none, "/example-schema:activeNumber"}, |
| 966 | {boost::none, "/example-schema:activePort"}, |
| 967 | {boost::none, "/example-schema:another-duration"}, |
| 968 | {boost::none, "/example-schema:b"}, |
| 969 | {boost::none, "/example-schema:b/b2"}, |
| 970 | {boost::none, "/example-schema:b/b2/b3"}, |
| 971 | {boost::none, "/example-schema:carry"}, |
| 972 | {boost::none, "/example-schema:clockSpeed"}, |
| 973 | {boost::none, "/example-schema:deprecatedLeaf"}, |
| 974 | {boost::none, "/example-schema:direction"}, |
| 975 | {boost::none, "/example-schema:duration"}, |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 976 | {boost::none, "/example-schema:dummyLeaf"}, |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 977 | {boost::none, "/example-schema:foodDrinkIdentLeaf"}, |
| 978 | {boost::none, "/example-schema:foodIdentLeaf"}, |
| 979 | {boost::none, "/example-schema:interface/caseEthernet/ethernet"}, |
| 980 | {boost::none, "/example-schema:interface/caseEthernet/ethernet/ip"}, |
| 981 | {boost::none, "/example-schema:interface/caseLoopback/loopback"}, |
| 982 | {boost::none, "/example-schema:interface/caseLoopback/loopback/ip"}, |
| 983 | {boost::none, "/example-schema:interrupt"}, |
| 984 | {boost::none, "/example-schema:leafBool"}, |
| 985 | {boost::none, "/example-schema:leafDecimal"}, |
| 986 | {boost::none, "/example-schema:leafEnum"}, |
| 987 | {boost::none, "/example-schema:leafEnumTypedef"}, |
| 988 | {boost::none, "/example-schema:leafEnumTypedefRestricted"}, |
| 989 | {boost::none, "/example-schema:leafEnumTypedefRestricted2"}, |
| 990 | {boost::none, "/example-schema:leafInt16"}, |
| 991 | {boost::none, "/example-schema:leafInt32"}, |
| 992 | {boost::none, "/example-schema:leafInt64"}, |
| 993 | {boost::none, "/example-schema:leafInt8"}, |
| 994 | {boost::none, "/example-schema:leafString"}, |
| 995 | {boost::none, "/example-schema:leafUint16"}, |
| 996 | {boost::none, "/example-schema:leafUint32"}, |
| 997 | {boost::none, "/example-schema:leafUint64"}, |
| 998 | {boost::none, "/example-schema:leafUint8"}, |
| 999 | {boost::none, "/example-schema:length"}, |
Václav Kubernát | aaafeae | 2020-05-05 15:41:45 +0200 | [diff] [blame] | 1000 | {boost::none, "/example-schema:myRpc"}, |
| 1001 | {boost::none, "/example-schema:myRpc/input"}, |
| 1002 | {boost::none, "/example-schema:myRpc/output"}, |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 1003 | {boost::none, "/example-schema:numberOrString"}, |
| 1004 | {boost::none, "/example-schema:obsoleteLeaf"}, |
| 1005 | {boost::none, "/example-schema:obsoleteLeafWithDeprecatedType"}, |
| 1006 | {boost::none, "/example-schema:obsoleteLeafWithObsoleteType"}, |
| 1007 | {boost::none, "/example-schema:pizzaIdentLeaf"}, |
| 1008 | {boost::none, "/example-schema:pizzaSize"}, |
| 1009 | {boost::none, "/example-schema:portMapping"}, |
| 1010 | {boost::none, "/example-schema:portMapping/port"}, |
| 1011 | {boost::none, "/example-schema:portSettings"}, |
| 1012 | {boost::none, "/example-schema:portSettings/port"}, |
| 1013 | {boost::none, "/example-schema:systemStats"}, |
| 1014 | {boost::none, "/example-schema:systemStats/upTime"}, |
Václav Kubernát | 82d7463 | 2020-05-11 15:59:53 +0200 | [diff] [blame] | 1015 | {boost::none, "/example-schema:subLeaf"}, |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 1016 | {boost::none, "/example-schema:twoKeyList"}, |
| 1017 | {boost::none, "/example-schema:twoKeyList/name"}, |
| 1018 | {boost::none, "/example-schema:twoKeyList/number"}, |
| 1019 | {boost::none, "/example-schema:wavelength"}, |
| 1020 | {boost::none, "/example-schema:zero"} |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 1021 | }; |
| 1022 | } |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 1023 | SECTION("second-schema") |
| 1024 | { |
| 1025 | module = "second-schema"; |
| 1026 | expectedNonRecursive = { |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 1027 | {"second-schema"s, "bla"} |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 1028 | }; |
| 1029 | expectedRecursive = { |
Václav Kubernát | 95b0887 | 2020-04-28 01:04:17 +0200 | [diff] [blame] | 1030 | {boost::none, "/second-schema:bla"}, |
| 1031 | {boost::none, "/second-schema:bla/bla2"} |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 1032 | }; |
| 1033 | } |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1034 | |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 1035 | REQUIRE(ys.availableNodes(module_{module}, Recursion::NonRecursive) == expectedNonRecursive); |
| 1036 | REQUIRE(ys.availableNodes(module_{module}, Recursion::Recursive) == expectedRecursive); |
Václav Kubernát | 47a3f67 | 2019-11-08 15:42:43 +0100 | [diff] [blame] | 1037 | } |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1038 | } |
Václav Kubernát | 34ee85a | 2020-02-18 17:12:12 +0100 | [diff] [blame] | 1039 | SECTION("nodeType") |
| 1040 | { |
| 1041 | yang::NodeTypes expected; |
| 1042 | SECTION("leafInt32") |
| 1043 | { |
| 1044 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("leafInt32"))); |
| 1045 | expected = yang::NodeTypes::Leaf; |
| 1046 | } |
| 1047 | |
| 1048 | SECTION("a") |
| 1049 | { |
| 1050 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a"))); |
| 1051 | expected = yang::NodeTypes::Container; |
| 1052 | } |
| 1053 | |
| 1054 | SECTION("a/a2/a3") |
| 1055 | { |
| 1056 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a"))); |
| 1057 | path.m_nodes.push_back(schemaNode_(container_("a2"))); |
| 1058 | path.m_nodes.push_back(schemaNode_(container_("a3"))); |
| 1059 | expected = yang::NodeTypes::PresenceContainer; |
| 1060 | } |
| 1061 | |
| 1062 | SECTION("_list") |
| 1063 | { |
| 1064 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, list_("_list"))); |
| 1065 | expected = yang::NodeTypes::List; |
| 1066 | } |
| 1067 | |
Václav Kubernát | 82d7463 | 2020-05-11 15:59:53 +0200 | [diff] [blame] | 1068 | SECTION("subLeaf") |
| 1069 | { |
| 1070 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("subLeaf"))); |
| 1071 | expected = yang::NodeTypes::Leaf; |
| 1072 | } |
| 1073 | |
Václav Kubernát | 34ee85a | 2020-02-18 17:12:12 +0100 | [diff] [blame] | 1074 | REQUIRE(ys.nodeType(pathToSchemaString(path, Prefixes::WhenNeeded)) == expected); |
| 1075 | } |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1076 | |
| 1077 | SECTION("description") |
| 1078 | { |
| 1079 | std::optional<std::string> expected; |
| 1080 | SECTION("leafInt32") |
| 1081 | { |
| 1082 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("leafInt32"))); |
| 1083 | expected = "A 32-bit integer leaf."; |
| 1084 | } |
| 1085 | |
| 1086 | SECTION("leafString") |
| 1087 | { |
| 1088 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("leafString"))); |
| 1089 | } |
| 1090 | |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 1091 | SECTION("numberOrString") |
| 1092 | { |
| 1093 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("numberOrString"))); |
| 1094 | expected = "Can be an int32 or a string."; |
| 1095 | } |
| 1096 | |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1097 | REQUIRE(ys.description(pathToSchemaString(path, Prefixes::WhenNeeded)) == expected); |
| 1098 | } |
| 1099 | |
Václav Kubernát | a1c4c9e | 2020-04-22 00:37:52 +0200 | [diff] [blame] | 1100 | SECTION("status") |
| 1101 | { |
| 1102 | REQUIRE(ys.status("/example-schema:leafUint64") == yang::Status::Current); |
| 1103 | REQUIRE(ys.status("/example-schema:obsoleteLeaf") == yang::Status::Obsolete); |
| 1104 | REQUIRE(ys.status("/example-schema:deprecatedLeaf") == yang::Status::Deprecated); |
| 1105 | REQUIRE(ys.status("/example-schema:obsoleteLeafWithDeprecatedType") == yang::Status::Obsolete); |
| 1106 | REQUIRE(ys.status("/example-schema:obsoleteLeafWithObsoleteType") == yang::Status::Obsolete); |
| 1107 | } |
| 1108 | |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1109 | SECTION("units") |
| 1110 | { |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 1111 | yang::LeafDataType expectedType; |
| 1112 | std::optional<std::string> expectedUnits; |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1113 | SECTION("length") |
| 1114 | { |
| 1115 | 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] | 1116 | expectedType.emplace<yang::Int32>(); |
| 1117 | expectedUnits = "m"; |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1118 | } |
| 1119 | |
| 1120 | SECTION("wavelength") |
| 1121 | { |
| 1122 | 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] | 1123 | expectedType.emplace<yang::Decimal>(); |
| 1124 | expectedUnits = "nm"; |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1125 | } |
| 1126 | |
| 1127 | SECTION("leafInt32") |
| 1128 | { |
| 1129 | 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] | 1130 | expectedType.emplace<yang::Int32>(); |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1131 | } |
| 1132 | |
| 1133 | SECTION("duration") |
| 1134 | { |
| 1135 | 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] | 1136 | expectedType.emplace<yang::Int32>(); |
| 1137 | expectedUnits = "s"; |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1138 | } |
| 1139 | |
| 1140 | SECTION("another-duration") |
| 1141 | { |
| 1142 | 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] | 1143 | expectedType.emplace<yang::Int32>(); |
| 1144 | expectedUnits = "vt"; |
Václav Kubernát | 1e09bd6 | 2020-02-17 15:13:38 +0100 | [diff] [blame] | 1145 | } |
Václav Kubernát | 5b8a8f3 | 2020-05-20 00:57:22 +0200 | [diff] [blame] | 1146 | auto nodeType = ys.nodeType(pathToSchemaString(path, Prefixes::WhenNeeded)); |
| 1147 | REQUIRE((nodeType == yang::NodeTypes::Leaf || nodeType == yang::NodeTypes::LeafList)); |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 1148 | 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] | 1149 | } |
| 1150 | |
| 1151 | SECTION("nodeType") |
| 1152 | { |
| 1153 | yang::NodeTypes expected; |
| 1154 | SECTION("leafInt32") |
| 1155 | { |
| 1156 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("leafInt32"))); |
| 1157 | expected = yang::NodeTypes::Leaf; |
| 1158 | } |
| 1159 | |
| 1160 | SECTION("a") |
| 1161 | { |
| 1162 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a"))); |
| 1163 | expected = yang::NodeTypes::Container; |
| 1164 | } |
| 1165 | |
| 1166 | SECTION("a/a2/a3") |
| 1167 | { |
| 1168 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a"))); |
| 1169 | path.m_nodes.push_back(schemaNode_(container_("a2"))); |
| 1170 | path.m_nodes.push_back(schemaNode_(container_("a3"))); |
| 1171 | expected = yang::NodeTypes::PresenceContainer; |
| 1172 | } |
| 1173 | |
| 1174 | SECTION("_list") |
| 1175 | { |
| 1176 | path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, list_("_list"))); |
| 1177 | expected = yang::NodeTypes::List; |
| 1178 | } |
| 1179 | |
| 1180 | REQUIRE(ys.nodeType(pathToSchemaString(path, Prefixes::WhenNeeded)) == expected); |
| 1181 | } |
Václav Kubernát | bd5e3c2 | 2020-02-19 15:22:00 +0100 | [diff] [blame] | 1182 | |
| 1183 | SECTION("leafrefPath") |
| 1184 | { |
| 1185 | REQUIRE(ys.leafrefPath("/example-schema:activeNumber") == "/example-schema:_list/number"); |
| 1186 | } |
Václav Kubernát | 0599e9f | 2020-04-21 09:51:33 +0200 | [diff] [blame] | 1187 | |
| 1188 | SECTION("isConfig") |
| 1189 | { |
| 1190 | REQUIRE(ys.isConfig("/example-schema:leafInt32")); |
| 1191 | REQUIRE_FALSE(ys.isConfig("/example-schema:clockSpeed")); |
| 1192 | REQUIRE_FALSE(ys.isConfig("/example-schema:systemStats")); |
| 1193 | REQUIRE_FALSE(ys.isConfig("/example-schema:systemStats/upTime")); |
| 1194 | } |
Václav Kubernát | bd0d5c8 | 2020-04-21 10:22:03 +0200 | [diff] [blame] | 1195 | |
Václav Kubernát | b1a75c6 | 2020-04-21 15:20:16 +0200 | [diff] [blame] | 1196 | SECTION("defaultValue") |
| 1197 | { |
| 1198 | REQUIRE(ys.defaultValue("/example-schema:leafUint64") == "9001"); |
| 1199 | REQUIRE(ys.defaultValue("/example-schema:leafEnumTypedefRestricted") == "data"); |
| 1200 | REQUIRE(ys.defaultValue("/example-schema:leafInt32") == std::nullopt); |
| 1201 | } |
| 1202 | |
Václav Kubernát | 76ba4ec | 2020-05-18 13:26:56 +0200 | [diff] [blame] | 1203 | SECTION("leafTypeName") |
| 1204 | { |
| 1205 | REQUIRE(ys.leafTypeName("/example-schema:leafEnumTypedefRestricted") == "enumTypedef"); |
| 1206 | REQUIRE(ys.leafTypeName("/example-schema:leafInt32") == std::nullopt); |
| 1207 | } |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1208 | } |
| 1209 | |
| 1210 | SECTION("negative") |
| 1211 | { |
| 1212 | SECTION("nonexistent nodes") |
| 1213 | { |
| 1214 | SECTION("example-schema:coze") |
| 1215 | { |
| 1216 | node.first = "example-schema"; |
| 1217 | node.second = "coze"; |
| 1218 | } |
| 1219 | |
| 1220 | SECTION("example-schema:a/nevim") |
| 1221 | { |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 1222 | 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] | 1223 | node.second = "nevim"; |
| 1224 | } |
| 1225 | |
| 1226 | SECTION("modul:a/nevim") |
| 1227 | { |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 1228 | path.m_nodes.push_back(schemaNode_(module_{"modul"}, container_("a"))); |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1229 | node.second = "nevim"; |
| 1230 | } |
| 1231 | |
| 1232 | REQUIRE(!ys.isPresenceContainer(path, node)); |
| 1233 | REQUIRE(!ys.isList(path, node)); |
| 1234 | REQUIRE(!ys.isLeaf(path, node)); |
| 1235 | REQUIRE(!ys.isContainer(path, node)); |
| 1236 | } |
| 1237 | |
| 1238 | SECTION("\"is\" methods return false for existing nodes for different nodetypes") |
| 1239 | { |
| 1240 | SECTION("example-schema:a") |
| 1241 | { |
| 1242 | node.first = "example-schema"; |
| 1243 | node.second = "a"; |
| 1244 | } |
| 1245 | |
| 1246 | SECTION("example-schema:a/a2") |
| 1247 | { |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 1248 | 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] | 1249 | node.second = "a2"; |
| 1250 | } |
| 1251 | |
| 1252 | REQUIRE(!ys.isPresenceContainer(path, node)); |
| 1253 | REQUIRE(!ys.isList(path, node)); |
| 1254 | REQUIRE(!ys.isLeaf(path, node)); |
| 1255 | } |
| 1256 | |
| 1257 | SECTION("nodetype-specific methods called with different nodetypes") |
| 1258 | { |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 1259 | 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] | 1260 | node.second = "a2"; |
| 1261 | |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1262 | REQUIRE(!ys.listHasKey(path, node, "chacha")); |
| 1263 | } |
| 1264 | |
| 1265 | SECTION("nonexistent module") |
| 1266 | { |
Václav Kubernát | 75877de | 2019-11-20 17:43:02 +0100 | [diff] [blame] | 1267 | REQUIRE(!ys.isModule("notAModule")); |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1268 | } |
Václav Kubernát | eeb3884 | 2019-03-20 19:46:05 +0100 | [diff] [blame] | 1269 | |
Václav Kubernát | 7d82da7 | 2019-04-11 15:16:38 +0200 | [diff] [blame] | 1270 | SECTION("grouping is not a node") |
| 1271 | { |
| 1272 | SECTION("example-schema:arithmeticFlags") |
| 1273 | { |
| 1274 | node.first = "example-schema"; |
| 1275 | node.second = "arithmeticFlags"; |
| 1276 | } |
| 1277 | |
| 1278 | SECTION("example-schema:flags") |
| 1279 | { |
| 1280 | node.first = "example-schema"; |
| 1281 | node.second = "startAndStop"; |
| 1282 | } |
| 1283 | |
| 1284 | REQUIRE(!ys.isPresenceContainer(path, node)); |
| 1285 | REQUIRE(!ys.isList(path, node)); |
| 1286 | REQUIRE(!ys.isLeaf(path, node)); |
| 1287 | REQUIRE(!ys.isContainer(path, node)); |
| 1288 | } |
Václav Kubernát | 280df4a | 2019-11-01 14:46:34 +0100 | [diff] [blame] | 1289 | |
| 1290 | SECTION("choice is not a node") |
| 1291 | { |
| 1292 | SECTION("example-schema:interface") |
| 1293 | { |
| 1294 | node.first = "example-schema"; |
| 1295 | node.second = "interface"; |
| 1296 | } |
| 1297 | |
| 1298 | REQUIRE(!ys.isPresenceContainer(path, node)); |
| 1299 | REQUIRE(!ys.isList(path, node)); |
| 1300 | REQUIRE(!ys.isLeaf(path, node)); |
| 1301 | REQUIRE(!ys.isContainer(path, node)); |
| 1302 | } |
| 1303 | |
| 1304 | SECTION("case is not a node") |
| 1305 | { |
| 1306 | SECTION("example-schema:caseLoopback") |
| 1307 | { |
| 1308 | node.first = "example-schema"; |
| 1309 | node.second = "caseLoopback"; |
| 1310 | } |
| 1311 | |
| 1312 | SECTION("example-schema:caseEthernet") |
| 1313 | { |
| 1314 | node.first = "example-schema"; |
| 1315 | node.second = "caseEthernet"; |
| 1316 | } |
| 1317 | |
| 1318 | REQUIRE(!ys.isPresenceContainer(path, node)); |
| 1319 | REQUIRE(!ys.isList(path, node)); |
| 1320 | REQUIRE(!ys.isLeaf(path, node)); |
| 1321 | REQUIRE(!ys.isContainer(path, node)); |
| 1322 | } |
Václav Kubernát | 0d4db44 | 2018-07-18 17:18:43 +0200 | [diff] [blame] | 1323 | } |
| 1324 | } |