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