blob: 3c658b3c4e899d8c0e9637ff7a3c9a64a42a58d9 [file] [log] [blame]
Václav Kubernát0d4db442018-07-18 17:18:43 +02001/*
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át47a3f672019-11-08 15:42:43 +01009#include <experimental/iterator>
Václav Kubernát3a99f002020-03-31 02:27:41 +020010#include "leaf_data_helpers.hpp"
Václav Kubernát1e09bd62020-02-17 15:13:38 +010011#include "pretty_printers.hpp"
Václav Kubernát26b56082020-02-03 18:28:56 +010012#include "trompeloeil_doctest.hpp"
Václav Kubernát0d4db442018-07-18 17:18:43 +020013#include "yang_schema.hpp"
14
Václav Kubernát4f77a252019-02-19 16:51:30 +010015const char* second_schema = R"(
16module second-schema {
17 namespace "http://example.com/nevim";
18 prefix second;
19
20 import example-schema {
21 prefix "example";
22 }
23
Václav Kubernáteeb38842019-03-20 19:46:05 +010024 identity pineapple {
25 base "example:fruit";
26 }
27
Václav Kubernát4f77a252019-02-19 16:51:30 +010028 augment /example:a {
29 container augmentedContainer {
30 }
31 }
32
33 container bla {
34 container bla2 {
35 }
36 }
37}
38)";
39
40const char* example_schema = R"(
Václav Kubernát0d4db442018-07-18 17:18:43 +020041module example-schema {
Václav Kubernát6a713d62018-10-03 18:47:34 +020042 yang-version 1.1;
Václav Kubernát0d4db442018-07-18 17:18:43 +020043 namespace "http://example.com/example-sports";
44 prefix coze;
45
Václav Kubernáteeb38842019-03-20 19:46:05 +010046 identity drink {
47 }
48
49 identity voda {
50 base "drink";
51 }
52
53 identity food {
54 }
55
56 identity fruit {
57 base "food";
58 }
59
60 identity pizza {
61 base "food";
62 }
63
64 identity hawaii {
65 base "pizza";
66 }
67
Václav Kubernát0d4db442018-07-18 17:18:43 +020068 container a {
69 container a2 {
70 container a3 {
71 presence true;
72 }
73 }
74
75 leaf leafa {
76 type string;
77 }
78 }
79
80 container b {
81 container b2 {
82 presence true;
83 container b3 {
84 }
85 }
86 }
87
88 leaf leafString {
89 type string;
90 }
91
92 leaf leafDecimal {
93 type decimal64 {
94 fraction-digits 5;
95 }
96 }
97
98 leaf leafBool {
99 type boolean;
100 }
101
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200102 leaf leafInt8 {
103 type int8;
104 }
105
106 leaf leafUint8 {
107 type uint8;
108 }
109
110 leaf leafInt16 {
111 type int16;
112 }
113
114 leaf leafUint16 {
115 type uint16;
116 }
117
118 leaf leafInt32 {
Václav Kubernát1e09bd62020-02-17 15:13:38 +0100119 description "A 32-bit integer leaf.";
Václav Kubernát0d4db442018-07-18 17:18:43 +0200120 type int32;
121 }
122
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200123 leaf leafUint32 {
Václav Kubernát0d4db442018-07-18 17:18:43 +0200124 type uint32;
125 }
126
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200127 leaf leafInt64 {
128 type int64;
129 }
130
131 leaf leafUint64 {
132 type uint64;
Václav Kubernátb1a75c62020-04-21 15:20:16 +0200133 default 9001;
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200134 }
135
Václav Kubernát0d4db442018-07-18 17:18:43 +0200136 leaf leafEnum {
137 type enumeration {
138 enum lol;
139 enum data;
140 enum coze;
141 }
142 }
143
Václav Kubernát6a713d62018-10-03 18:47:34 +0200144 typedef enumTypedef {
145 type enumeration {
146 enum lol;
147 enum data;
148 enum coze;
149 }
Václav Kubernátb1a75c62020-04-21 15:20:16 +0200150 default data;
Václav Kubernát6a713d62018-10-03 18:47:34 +0200151 }
152
153 typedef enumTypedefRestricted {
154 type enumTypedef {
155 enum lol;
156 enum data;
157 }
158 }
159
160 leaf leafEnumTypedef {
161 type enumTypedef;
162 }
163
164 leaf leafEnumTypedefRestricted {
165 type enumTypedef {
166 enum data;
167 enum coze;
168 }
169 }
170
171 leaf leafEnumTypedefRestricted2 {
172 type enumTypedefRestricted;
173 }
174
Václav Kubernáteeb38842019-03-20 19:46:05 +0100175 leaf foodIdentLeaf {
176 type identityref {
177 base "food";
178 }
179 }
180
181 leaf pizzaIdentLeaf {
182 type identityref {
183 base "pizza";
184 }
185 }
186
187 leaf foodDrinkIdentLeaf {
188 type identityref {
189 base "food";
190 base "drink";
191 }
192 }
193
Václav Kubernát0d4db442018-07-18 17:18:43 +0200194 list _list {
195 key number;
196
197 leaf number {
198 type int32;
199 }
200
201 container contInList {
202 presence true;
203 }
204 }
205
206 list twoKeyList {
207 key "name number";
208
209 leaf number {
210 type int32;
211 }
212
213 leaf name {
214 type string;
215 }
216 }
Václav Kubernát7d82da72019-04-11 15:16:38 +0200217
218 grouping arithmeticFlags {
219 leaf carry {
220 type boolean;
221 }
222 leaf zero {
223 type boolean;
224 }
225 }
226
227 grouping flags {
228 leaf direction {
229 type boolean;
230 }
231 leaf interrupt {
232 type boolean;
233 }
234
235 uses arithmeticFlags;
236 }
237
238 uses flags;
Václav Kubernát280df4a2019-11-01 14:46:34 +0100239
240 choice interface {
241 case caseLoopback {
242 container loopback {
243 leaf ip {
244 type string;
245 }
246 }
247 }
248
249 case caseEthernet {
250 container ethernet {
251 leaf ip {
252 type string;
253 }
254 }
255 }
256 }
257
Václav Kubernáta38d4172019-11-04 12:36:39 +0100258 feature bigPizzas;
259
260 leaf pizzaSize {
261 type enumeration {
262 enum large {
263 if-feature "bigPizzas";
264 }
265 enum medium;
266 enum small;
267 }
268 }
269
Václav Kubernát1e09bd62020-02-17 15:13:38 +0100270 leaf length {
271 type int32;
272 units "m";
273 }
274
275 leaf wavelength {
276 type decimal64 {
277 fraction-digits 10;
278 }
279 units "nm";
280 }
281
282 typedef seconds {
283 type int32;
284 units "s";
285 }
286
287 leaf duration {
288 type seconds;
289 }
290
291 leaf another-duration {
292 type seconds;
293 units "vt";
294 }
295
Václav Kubernátbd5e3c22020-02-19 15:22:00 +0100296 leaf activeNumber {
297 type leafref {
298 path "/_list/number";
299 }
300 }
301
Václav Kubernátfa81c8c2020-02-13 17:22:46 +0100302 rpc myRpc {}
303
Václav Kubernát2984f442020-02-20 17:43:35 +0100304 leaf numberOrString {
305 type union {
306 type int32;
307 type string;
308 }
309 description "Can be an int32 or a string.";
310 }
311
312 list portSettings {
313 key "port";
314 leaf port {
315 type enumeration {
316 enum eth0;
317 enum eth1;
318 enum eth2;
319 }
320 }
321 }
322
323 feature weirdPortNames;
324
325 list portMapping {
326 key "port";
327 leaf port {
328 type enumeration {
329 enum WEIRD {
330 if-feature "weirdPortNames";
331 }
332 enum utf2;
333 enum utf3;
334 }
335 }
336 }
337
338 leaf activeMappedPort {
339 type leafref {
340 path "../portMapping/port";
341 }
342 }
343
344 leaf activePort {
345 type union {
346 type enumeration {
347 enum wlan0;
348 enum wlan1;
349 }
350 type leafref {
351 path "../portSettings/port";
352 }
353 type leafref {
354 path "../activeMappedPort";
355 }
356 }
357 }
358
Václav Kubernát0599e9f2020-04-21 09:51:33 +0200359 leaf clockSpeed {
360 type int64;
361 config false;
362 }
363
364 container systemStats {
365 config false;
366 leaf upTime {
367 type uint64;
368 }
369 }
370
Václav Kubernáta1c4c9e2020-04-22 00:37:52 +0200371 leaf obsoleteLeaf {
372 type int32;
373 status obsolete;
374 }
375
376 leaf deprecatedLeaf {
377 type int32;
378 status deprecated;
379 }
380
381 typedef deprecatedType {
382 type int32;
383 status deprecated;
384 }
385
386 leaf obsoleteLeafWithDeprecatedType {
387 type deprecatedType;
388 status obsolete;
389 }
390
391 typedef obsoleteType {
392 type int32;
393 status obsolete;
394 }
395
396 leaf obsoleteLeafWithObsoleteType {
397 type deprecatedType;
398 status obsolete;
399 }
400
Václav Kubernát0d4db442018-07-18 17:18:43 +0200401})";
402
Václav Kubernát47a3f672019-11-08 15:42:43 +0100403namespace std {
404std::ostream& operator<<(std::ostream& s, const std::set<std::string> set)
405{
406 s << std::endl << "{";
407 std::copy(set.begin(), set.end(), std::experimental::make_ostream_joiner(s, ", "));
408 s << "}" << std::endl;
409 return s;
410}
411}
412
Václav Kubernát0d4db442018-07-18 17:18:43 +0200413TEST_CASE("yangschema")
414{
Václav Kubernát4f77a252019-02-19 16:51:30 +0100415 using namespace std::string_view_literals;
Václav Kubernát0d4db442018-07-18 17:18:43 +0200416 YangSchema ys;
Václav Kubernátb52dc252019-12-04 13:03:39 +0100417 ys.registerModuleCallback([]([[maybe_unused]] auto modName, auto, auto, auto) {
Václav Kubernát4f77a252019-02-19 16:51:30 +0100418 assert("example-schema"sv == modName);
419 return example_schema;
420 });
421 ys.addSchemaString(second_schema);
422
Václav Kubernátefcac932020-01-10 15:26:32 +0100423 schemaPath_ path{Scope::Absolute, {}};
Václav Kubernát0d4db442018-07-18 17:18:43 +0200424 ModuleNodePair node;
425
426 SECTION("positive")
427 {
428 SECTION("isContainer")
429 {
430 SECTION("example-schema:a")
431 {
432 node.first = "example-schema";
433 node.second = "a";
434 }
435
436 SECTION("example-schema:a/a2")
437 {
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200438 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
Václav Kubernát0d4db442018-07-18 17:18:43 +0200439 node.second = "a2";
440 }
441
Václav Kubernát280df4a2019-11-01 14:46:34 +0100442 SECTION("example-schema:ethernet")
443 {
444 node.first = "example-schema";
445 node.second = "ethernet";
446 }
447
448 SECTION("example-schema:loopback")
449 {
450 node.first = "example-schema";
451 node.second = "loopback";
452 }
453
Václav Kubernát0d4db442018-07-18 17:18:43 +0200454 REQUIRE(ys.isContainer(path, node));
455 }
456 SECTION("isLeaf")
457 {
458 SECTION("example-schema:leafString")
459 {
460 node.first = "example-schema";
461 node.second = "leafString";
462 }
463
464 SECTION("example-schema:a/leafa")
465 {
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200466 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
Václav Kubernát0d4db442018-07-18 17:18:43 +0200467 node.first = "example-schema";
468 node.second = "leafa";
469 }
470
Václav Kubernát7d82da72019-04-11 15:16:38 +0200471 SECTION("example-schema:carry")
472 {
473 node.first = "example-schema";
474 node.second = "carry";
475 }
476
477 SECTION("example-schema:zero")
478 {
479 node.first = "example-schema";
480 node.second = "zero";
481 }
482
483 SECTION("example-schema:direction")
484 {
485 node.first = "example-schema";
486 node.second = "direction";
487 }
488
489 SECTION("example-schema:interrupt")
490 {
491 node.first = "example-schema";
492 node.second = "interrupt";
493 }
494
Václav Kubernát0d4db442018-07-18 17:18:43 +0200495 REQUIRE(ys.isLeaf(path, node));
496 }
497 SECTION("isModule")
498 {
Václav Kubernát75877de2019-11-20 17:43:02 +0100499 REQUIRE(ys.isModule("example-schema"));
Václav Kubernát0d4db442018-07-18 17:18:43 +0200500 }
501 SECTION("isList")
502 {
503 SECTION("example-schema:_list")
504 {
505 node.first = "example-schema";
506 node.second = "_list";
507 }
508
509 SECTION("example-schema:twoKeyList")
510 {
511 node.first = "example-schema";
512 node.second = "twoKeyList";
513 }
514
515 REQUIRE(ys.isList(path, node));
516 }
517 SECTION("isPresenceContainer")
518 {
519 SECTION("example-schema:a/a2/a3")
520 {
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200521 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
522 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a2")));
Václav Kubernát0d4db442018-07-18 17:18:43 +0200523 node.second = "a3";
524 }
525
526 REQUIRE(ys.isPresenceContainer(path, node));
527 }
Václav Kubernáteeb38842019-03-20 19:46:05 +0100528
Václav Kubernát0d4db442018-07-18 17:18:43 +0200529 SECTION("listHasKey")
530 {
531 std::string key;
532
533 SECTION("_list")
534 {
535 node.first = "example-schema";
536 node.second = "_list";
537 SECTION("number")
538 key = "number";
539 }
540
541 SECTION("twoKeyList")
542 {
543 node.first = "example-schema";
544 node.second = "twoKeyList";
545 SECTION("number")
546 key = "number";
547 SECTION("name")
548 key = "name";
549 }
550
551 REQUIRE(ys.listHasKey(path, node, key));
552 }
553 SECTION("listKeys")
554 {
555 std::set<std::string> set;
556
557 SECTION("_list")
558 {
559 set = {"number"};
560 node.first = "example-schema";
561 node.second = "_list";
562 }
563
564 SECTION("twoKeyList")
565 {
566 set = {"number", "name"};
567 node.first = "example-schema";
568 node.second = "twoKeyList";
569 }
570
571 REQUIRE(ys.listKeys(path, node) == set);
572 }
573 SECTION("leafType")
574 {
Václav Kubernát3a99f002020-03-31 02:27:41 +0200575 yang::LeafDataType type;
Václav Kubernát0d4db442018-07-18 17:18:43 +0200576
577 SECTION("leafString")
578 {
579 node.first = "example-schema";
580 node.second = "leafString";
Václav Kubernát3a99f002020-03-31 02:27:41 +0200581 type = yang::String{};
Václav Kubernát0d4db442018-07-18 17:18:43 +0200582 }
583
584 SECTION("leafDecimal")
585 {
586 node.first = "example-schema";
587 node.second = "leafDecimal";
Václav Kubernát3a99f002020-03-31 02:27:41 +0200588 type = yang::Decimal{};
Václav Kubernát0d4db442018-07-18 17:18:43 +0200589 }
590
591 SECTION("leafBool")
592 {
593 node.first = "example-schema";
594 node.second = "leafBool";
Václav Kubernát3a99f002020-03-31 02:27:41 +0200595 type = yang::Bool{};
Václav Kubernát0d4db442018-07-18 17:18:43 +0200596 }
597
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200598 SECTION("leafInt8")
Václav Kubernát0d4db442018-07-18 17:18:43 +0200599 {
600 node.first = "example-schema";
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200601 node.second = "leafInt8";
Václav Kubernát3a99f002020-03-31 02:27:41 +0200602 type = yang::Int8{};
Václav Kubernát0d4db442018-07-18 17:18:43 +0200603 }
604
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200605 SECTION("leafUint8")
Václav Kubernát0d4db442018-07-18 17:18:43 +0200606 {
607 node.first = "example-schema";
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200608 node.second = "leafUint8";
Václav Kubernát3a99f002020-03-31 02:27:41 +0200609 type = yang::Uint8{};
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200610 }
611
Václav Kubernátb6d02752020-04-03 00:25:10 +0200612 SECTION("leafInt16")
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200613 {
614 node.first = "example-schema";
615 node.second = "leafInt16";
Václav Kubernát3a99f002020-03-31 02:27:41 +0200616 type = yang::Int16{};
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200617 }
618
619 SECTION("leafUint16")
620 {
621 node.first = "example-schema";
622 node.second = "leafUint16";
Václav Kubernát3a99f002020-03-31 02:27:41 +0200623 type = yang::Uint16{};
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200624 }
625
626 SECTION("leafInt32")
627 {
628 node.first = "example-schema";
629 node.second = "leafInt32";
Václav Kubernát3a99f002020-03-31 02:27:41 +0200630 type = yang::Int32{};
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200631 }
632
633 SECTION("leafUint32")
634 {
635 node.first = "example-schema";
636 node.second = "leafUint32";
Václav Kubernát3a99f002020-03-31 02:27:41 +0200637 type = yang::Uint32{};
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200638 }
639
640 SECTION("leafInt64")
641 {
642 node.first = "example-schema";
643 node.second = "leafInt64";
Václav Kubernát3a99f002020-03-31 02:27:41 +0200644 type = yang::Int64{};
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200645 }
646
647 SECTION("leafUint64")
648 {
649 node.first = "example-schema";
650 node.second = "leafUint64";
Václav Kubernát3a99f002020-03-31 02:27:41 +0200651 type = yang::Uint64{};
Václav Kubernát0d4db442018-07-18 17:18:43 +0200652 }
653
654 SECTION("leafEnum")
655 {
656 node.first = "example-schema";
657 node.second = "leafEnum";
Václav Kubernát3a99f002020-03-31 02:27:41 +0200658 type = createEnum({"lol", "data", "coze"});
659 }
660
661 SECTION("leafEnumTypedef")
662 {
663 node.first = "example-schema";
664 node.second = "leafEnumTypedef";
665 type = createEnum({"lol", "data", "coze"});
666 }
667
668 SECTION("leafEnumTypedefRestricted")
669 {
670 node.first = "example-schema";
671 node.second = "leafEnumTypedefRestricted";
672 type = createEnum({"data", "coze"});
673 }
674
675 SECTION("leafEnumTypedefRestricted2")
676 {
677 node.first = "example-schema";
678 node.second = "leafEnumTypedefRestricted2";
679 type = createEnum({"lol", "data"});
680 }
681
682 SECTION("pizzaSize")
683 {
684 node.first = "example-schema";
685 node.second = "pizzaSize";
686
687 SECTION("bigPizzas disabled")
688 {
689 type = createEnum({"small", "medium"});
690 }
691 SECTION("bigPizzas enabled")
692 {
693 ys.enableFeature("example-schema", "bigPizzas");
694 type = createEnum({"small", "medium", "large"});
695 }
696 }
697
698 SECTION("foodIdentLeaf")
699 {
700 node.first = "example-schema";
701 node.second = "foodIdentLeaf";
702 type = yang::IdentityRef{{{"second-schema", "pineapple"},
703 {"example-schema", "food"},
704 {"example-schema", "pizza"},
705 {"example-schema", "hawaii"},
706 {"example-schema", "fruit"}}};
707 }
708
709 SECTION("pizzaIdentLeaf")
710 {
711 node.first = "example-schema";
712 node.second = "pizzaIdentLeaf";
713
714 type = yang::IdentityRef{{
715 {"example-schema", "pizza"},
716 {"example-schema", "hawaii"},
717 }};
718 }
719
720 SECTION("foodDrinkIdentLeaf")
721 {
722 node.first = "example-schema";
723 node.second = "foodDrinkIdentLeaf";
724
725 type = yang::IdentityRef{{
726 {"example-schema", "food"},
727 {"example-schema", "drink"},
728 {"example-schema", "fruit"},
729 {"example-schema", "hawaii"},
730 {"example-schema", "pizza"},
731 {"example-schema", "voda"},
732 {"second-schema", "pineapple"},
733 }};
Václav Kubernát0d4db442018-07-18 17:18:43 +0200734 }
735
Václav Kubernátb6d02752020-04-03 00:25:10 +0200736 SECTION("activeNumber")
737 {
738 node.first = "example-schema";
739 node.second = "activeNumber";
Václav Kubernát3a99f002020-03-31 02:27:41 +0200740 type.emplace<yang::LeafRef>(
741 "/example-schema:_list/number",
Václav Kubernát13b23d72020-04-16 21:49:51 +0200742 std::make_unique<yang::TypeInfo>(ys.leafType("/example-schema:_list/number"))
Václav Kubernát3a99f002020-03-31 02:27:41 +0200743 );
Václav Kubernátb6d02752020-04-03 00:25:10 +0200744 }
745
Václav Kubernát2984f442020-02-20 17:43:35 +0100746 SECTION("activePort")
747 {
748 node.first = "example-schema";
749 node.second = "activePort";
750
751 yang::Enum enums = [&ys]() {
752 SECTION("weird ports disabled")
753 {
754 return createEnum({"utf2", "utf3"});
755 }
756 SECTION("weird ports enabled")
757 {
758 ys.enableFeature("example-schema", "weirdPortNames");
759 return createEnum({"WEIRD", "utf2", "utf3"});
760 }
761 __builtin_unreachable();
762 }();
763
764 type = yang::Union{{
Václav Kubernát13b23d72020-04-16 21:49:51 +0200765 yang::TypeInfo{createEnum({"wlan0", "wlan1"})},
766 yang::TypeInfo{yang::LeafRef{
Václav Kubernát2984f442020-02-20 17:43:35 +0100767 "/example-schema:portSettings/port",
Václav Kubernát13b23d72020-04-16 21:49:51 +0200768 std::make_unique<yang::TypeInfo>(createEnum({"eth0", "eth1", "eth2"}))
769 }},
770 yang::TypeInfo{yang::LeafRef{
Václav Kubernát2984f442020-02-20 17:43:35 +0100771 "/example-schema:activeMappedPort",
Václav Kubernát13b23d72020-04-16 21:49:51 +0200772 std::make_unique<yang::TypeInfo>(yang::LeafRef{
Václav Kubernát2984f442020-02-20 17:43:35 +0100773 "/example-schema:portMapping/port",
Václav Kubernát13b23d72020-04-16 21:49:51 +0200774 std::make_unique<yang::TypeInfo>(enums)
775 })
776 }},
Václav Kubernát2984f442020-02-20 17:43:35 +0100777 }};
778 }
779
Václav Kubernát0d4db442018-07-18 17:18:43 +0200780 REQUIRE(ys.leafType(path, node) == type);
781 }
Václav Kubernát3a823f42020-04-29 23:40:21 +0200782 SECTION("availableNodes")
Václav Kubernát0d4db442018-07-18 17:18:43 +0200783 {
Václav Kubernát3a823f42020-04-29 23:40:21 +0200784 // TODO: merge "path" and "module" sections and add recursive versions to the path section
785 SECTION("paths")
Václav Kubernát0d4db442018-07-18 17:18:43 +0200786 {
Václav Kubernát95b08872020-04-28 01:04:17 +0200787 std::set<ModuleNodePair> set;
Václav Kubernát3a823f42020-04-29 23:40:21 +0200788
Václav Kubernát95b08872020-04-28 01:04:17 +0200789 using namespace std::string_literals;
Václav Kubernát3a823f42020-04-29 23:40:21 +0200790 SECTION("<root>")
791 {
Václav Kubernát95b08872020-04-28 01:04:17 +0200792 set = {{"example-schema"s, "a"}, {"example-schema"s, "b"}, {"example-schema"s, "leafString"},
793 {"example-schema"s, "leafDecimal"}, {"example-schema"s, "leafBool"},
794 {"example-schema"s, "leafInt8"}, {"example-schema"s, "leafUint8"},
795 {"example-schema"s, "leafInt16"}, {"example-schema"s, "leafUint16"},
796 {"example-schema"s, "leafInt32"}, {"example-schema"s, "leafUint32"},
797 {"example-schema"s, "leafInt64"}, {"example-schema"s, "leafUint64"},
798 {"example-schema"s, "leafEnum"}, {"example-schema"s, "leafEnumTypedef"},
799 {"example-schema"s, "leafEnumTypedefRestricted"}, {"example-schema"s, "leafEnumTypedefRestricted2"},
800 {"example-schema"s, "foodIdentLeaf"}, {"example-schema"s, "pizzaIdentLeaf"}, {"example-schema"s, "foodDrinkIdentLeaf"},
801 {"example-schema"s, "_list"}, {"example-schema"s, "twoKeyList"}, {"second-schema"s, "bla"},
802 {"example-schema"s, "carry"}, {"example-schema"s, "zero"}, {"example-schema"s, "direction"},
803 {"example-schema"s, "interrupt"},
804 {"example-schema"s, "ethernet"}, {"example-schema"s, "loopback"},
805 {"example-schema"s, "pizzaSize"},
806 {"example-schema"s, "length"}, {"example-schema"s, "wavelength"},
807 {"example-schema"s, "duration"}, {"example-schema"s, "another-duration"},
808 {"example-schema"s, "activeNumber"},
809 {"example-schema"s, "numberOrString"},
810 {"example-schema"s, "portSettings"},
811 {"example-schema"s, "portMapping"},
812 {"example-schema"s, "activeMappedPort"},
813 {"example-schema"s, "activePort"},
814 {"example-schema"s, "clockSpeed"},
815 {"example-schema"s, "deprecatedLeaf"},
816 {"example-schema"s, "obsoleteLeaf"},
817 {"example-schema"s, "obsoleteLeafWithDeprecatedType"},
818 {"example-schema"s, "obsoleteLeafWithObsoleteType"},
Václav Kubernátaaafeae2020-05-05 15:41:45 +0200819 {"example-schema"s, "myRpc"},
Václav Kubernát95b08872020-04-28 01:04:17 +0200820 {"example-schema"s, "systemStats"}};
Václav Kubernát3a823f42020-04-29 23:40:21 +0200821 }
822
823 SECTION("example-schema:a")
824 {
825 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
Václav Kubernát95b08872020-04-28 01:04:17 +0200826 set = {
827 {boost::none, "a2"},
828 {boost::none, "leafa"},
829 {"second-schema"s, "augmentedContainer"}
830 };
Václav Kubernát3a823f42020-04-29 23:40:21 +0200831 }
832
833 SECTION("example-schema:ethernet")
834 {
835 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("ethernet")));
Václav Kubernát95b08872020-04-28 01:04:17 +0200836 set = {{boost::none, "ip"}};
837 }
838
839 SECTION("second-schema:bla")
840 {
841 path.m_nodes.push_back(schemaNode_(module_{"second-schema"}, container_("bla")));
842 set = {{boost::none, "bla2"}};
Václav Kubernát3a823f42020-04-29 23:40:21 +0200843 }
844
845 REQUIRE(ys.availableNodes(path, Recursion::NonRecursive) == set);
Václav Kubernát0d4db442018-07-18 17:18:43 +0200846 }
847
Václav Kubernát3a823f42020-04-29 23:40:21 +0200848 SECTION("modules")
Václav Kubernát0d4db442018-07-18 17:18:43 +0200849 {
Václav Kubernát3a823f42020-04-29 23:40:21 +0200850 std::string module;
Václav Kubernát95b08872020-04-28 01:04:17 +0200851 std::set<ModuleNodePair> expectedNonRecursive;
852 std::set<ModuleNodePair> expectedRecursive;
853 using namespace std::string_literals;
Václav Kubernát3a823f42020-04-29 23:40:21 +0200854 SECTION("example-schema")
855 {
856 module = "example-schema";
857 expectedNonRecursive = {
Václav Kubernát95b08872020-04-28 01:04:17 +0200858 {"example-schema"s, "_list"},
859 {"example-schema"s, "a"},
860 {"example-schema"s, "activeMappedPort"},
861 {"example-schema"s, "activeNumber"},
862 {"example-schema"s, "activePort"},
863 {"example-schema"s, "another-duration"},
864 {"example-schema"s, "b"},
865 {"example-schema"s, "carry"},
866 {"example-schema"s, "clockSpeed"},
867 {"example-schema"s, "deprecatedLeaf"},
868 {"example-schema"s, "direction"},
869 {"example-schema"s, "duration"},
870 {"example-schema"s, "ethernet"},
871 {"example-schema"s, "foodDrinkIdentLeaf"},
872 {"example-schema"s, "foodIdentLeaf"},
873 {"example-schema"s, "interrupt"},
874 {"example-schema"s, "leafBool"},
875 {"example-schema"s, "leafDecimal"},
876 {"example-schema"s, "leafEnum"},
877 {"example-schema"s, "leafEnumTypedef"},
878 {"example-schema"s, "leafEnumTypedefRestricted"},
879 {"example-schema"s, "leafEnumTypedefRestricted2"},
880 {"example-schema"s, "leafInt16"},
881 {"example-schema"s, "leafInt32"},
882 {"example-schema"s, "leafInt64"},
883 {"example-schema"s, "leafInt8"},
884 {"example-schema"s, "leafString"},
885 {"example-schema"s, "leafUint16"},
886 {"example-schema"s, "leafUint32"},
887 {"example-schema"s, "leafUint64"},
888 {"example-schema"s, "leafUint8"},
889 {"example-schema"s, "length"},
890 {"example-schema"s, "loopback"},
Václav Kubernátaaafeae2020-05-05 15:41:45 +0200891 {"example-schema"s, "myRpc"},
Václav Kubernát95b08872020-04-28 01:04:17 +0200892 {"example-schema"s, "numberOrString"},
893 {"example-schema"s, "obsoleteLeaf"},
894 {"example-schema"s, "obsoleteLeafWithDeprecatedType"},
895 {"example-schema"s, "obsoleteLeafWithObsoleteType"},
896 {"example-schema"s, "pizzaIdentLeaf"},
897 {"example-schema"s, "pizzaSize"},
898 {"example-schema"s, "portMapping"},
899 {"example-schema"s, "portSettings"},
900 {"example-schema"s, "systemStats"},
901 {"example-schema"s, "twoKeyList"},
902 {"example-schema"s, "wavelength"},
903 {"example-schema"s, "zero"}
Václav Kubernát3a823f42020-04-29 23:40:21 +0200904 };
905 expectedRecursive = {
Václav Kubernát95b08872020-04-28 01:04:17 +0200906 {boost::none, "/example-schema:_list"},
907 {boost::none, "/example-schema:_list/contInList"},
908 {boost::none, "/example-schema:_list/number"},
909 {boost::none, "/example-schema:a"},
910 {boost::none, "/example-schema:a/a2"},
911 {boost::none, "/example-schema:a/a2/a3"},
912 {boost::none, "/example-schema:a/leafa"},
913 {boost::none, "/example-schema:a/second-schema:augmentedContainer"},
914 {boost::none, "/example-schema:activeMappedPort"},
915 {boost::none, "/example-schema:activeNumber"},
916 {boost::none, "/example-schema:activePort"},
917 {boost::none, "/example-schema:another-duration"},
918 {boost::none, "/example-schema:b"},
919 {boost::none, "/example-schema:b/b2"},
920 {boost::none, "/example-schema:b/b2/b3"},
921 {boost::none, "/example-schema:carry"},
922 {boost::none, "/example-schema:clockSpeed"},
923 {boost::none, "/example-schema:deprecatedLeaf"},
924 {boost::none, "/example-schema:direction"},
925 {boost::none, "/example-schema:duration"},
926 {boost::none, "/example-schema:foodDrinkIdentLeaf"},
927 {boost::none, "/example-schema:foodIdentLeaf"},
928 {boost::none, "/example-schema:interface/caseEthernet/ethernet"},
929 {boost::none, "/example-schema:interface/caseEthernet/ethernet/ip"},
930 {boost::none, "/example-schema:interface/caseLoopback/loopback"},
931 {boost::none, "/example-schema:interface/caseLoopback/loopback/ip"},
932 {boost::none, "/example-schema:interrupt"},
933 {boost::none, "/example-schema:leafBool"},
934 {boost::none, "/example-schema:leafDecimal"},
935 {boost::none, "/example-schema:leafEnum"},
936 {boost::none, "/example-schema:leafEnumTypedef"},
937 {boost::none, "/example-schema:leafEnumTypedefRestricted"},
938 {boost::none, "/example-schema:leafEnumTypedefRestricted2"},
939 {boost::none, "/example-schema:leafInt16"},
940 {boost::none, "/example-schema:leafInt32"},
941 {boost::none, "/example-schema:leafInt64"},
942 {boost::none, "/example-schema:leafInt8"},
943 {boost::none, "/example-schema:leafString"},
944 {boost::none, "/example-schema:leafUint16"},
945 {boost::none, "/example-schema:leafUint32"},
946 {boost::none, "/example-schema:leafUint64"},
947 {boost::none, "/example-schema:leafUint8"},
948 {boost::none, "/example-schema:length"},
Václav Kubernátaaafeae2020-05-05 15:41:45 +0200949 {boost::none, "/example-schema:myRpc"},
950 {boost::none, "/example-schema:myRpc/input"},
951 {boost::none, "/example-schema:myRpc/output"},
Václav Kubernát95b08872020-04-28 01:04:17 +0200952 {boost::none, "/example-schema:numberOrString"},
953 {boost::none, "/example-schema:obsoleteLeaf"},
954 {boost::none, "/example-schema:obsoleteLeafWithDeprecatedType"},
955 {boost::none, "/example-schema:obsoleteLeafWithObsoleteType"},
956 {boost::none, "/example-schema:pizzaIdentLeaf"},
957 {boost::none, "/example-schema:pizzaSize"},
958 {boost::none, "/example-schema:portMapping"},
959 {boost::none, "/example-schema:portMapping/port"},
960 {boost::none, "/example-schema:portSettings"},
961 {boost::none, "/example-schema:portSettings/port"},
962 {boost::none, "/example-schema:systemStats"},
963 {boost::none, "/example-schema:systemStats/upTime"},
964 {boost::none, "/example-schema:twoKeyList"},
965 {boost::none, "/example-schema:twoKeyList/name"},
966 {boost::none, "/example-schema:twoKeyList/number"},
967 {boost::none, "/example-schema:wavelength"},
968 {boost::none, "/example-schema:zero"}
Václav Kubernát3a823f42020-04-29 23:40:21 +0200969 };
970 }
Václav Kubernát3a823f42020-04-29 23:40:21 +0200971 SECTION("second-schema")
972 {
973 module = "second-schema";
974 expectedNonRecursive = {
Václav Kubernát95b08872020-04-28 01:04:17 +0200975 {"second-schema"s, "bla"}
Václav Kubernát3a823f42020-04-29 23:40:21 +0200976 };
977 expectedRecursive = {
Václav Kubernát95b08872020-04-28 01:04:17 +0200978 {boost::none, "/second-schema:bla"},
979 {boost::none, "/second-schema:bla/bla2"}
Václav Kubernát3a823f42020-04-29 23:40:21 +0200980 };
981 }
Václav Kubernát0d4db442018-07-18 17:18:43 +0200982
Václav Kubernát3a823f42020-04-29 23:40:21 +0200983 REQUIRE(ys.availableNodes(module_{module}, Recursion::NonRecursive) == expectedNonRecursive);
984 REQUIRE(ys.availableNodes(module_{module}, Recursion::Recursive) == expectedRecursive);
Václav Kubernát47a3f672019-11-08 15:42:43 +0100985 }
Václav Kubernát0d4db442018-07-18 17:18:43 +0200986 }
Václav Kubernát34ee85a2020-02-18 17:12:12 +0100987 SECTION("nodeType")
988 {
989 yang::NodeTypes expected;
990 SECTION("leafInt32")
991 {
992 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("leafInt32")));
993 expected = yang::NodeTypes::Leaf;
994 }
995
996 SECTION("a")
997 {
998 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
999 expected = yang::NodeTypes::Container;
1000 }
1001
1002 SECTION("a/a2/a3")
1003 {
1004 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
1005 path.m_nodes.push_back(schemaNode_(container_("a2")));
1006 path.m_nodes.push_back(schemaNode_(container_("a3")));
1007 expected = yang::NodeTypes::PresenceContainer;
1008 }
1009
1010 SECTION("_list")
1011 {
1012 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, list_("_list")));
1013 expected = yang::NodeTypes::List;
1014 }
1015
1016 REQUIRE(ys.nodeType(pathToSchemaString(path, Prefixes::WhenNeeded)) == expected);
1017 }
Václav Kubernát1e09bd62020-02-17 15:13:38 +01001018
1019 SECTION("description")
1020 {
1021 std::optional<std::string> expected;
1022 SECTION("leafInt32")
1023 {
1024 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("leafInt32")));
1025 expected = "A 32-bit integer leaf.";
1026 }
1027
1028 SECTION("leafString")
1029 {
1030 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("leafString")));
1031 }
1032
Václav Kubernát2984f442020-02-20 17:43:35 +01001033 SECTION("numberOrString")
1034 {
1035 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("numberOrString")));
1036 expected = "Can be an int32 or a string.";
1037 }
1038
Václav Kubernát1e09bd62020-02-17 15:13:38 +01001039 REQUIRE(ys.description(pathToSchemaString(path, Prefixes::WhenNeeded)) == expected);
1040 }
1041
Václav Kubernáta1c4c9e2020-04-22 00:37:52 +02001042 SECTION("status")
1043 {
1044 REQUIRE(ys.status("/example-schema:leafUint64") == yang::Status::Current);
1045 REQUIRE(ys.status("/example-schema:obsoleteLeaf") == yang::Status::Obsolete);
1046 REQUIRE(ys.status("/example-schema:deprecatedLeaf") == yang::Status::Deprecated);
1047 REQUIRE(ys.status("/example-schema:obsoleteLeafWithDeprecatedType") == yang::Status::Obsolete);
1048 REQUIRE(ys.status("/example-schema:obsoleteLeafWithObsoleteType") == yang::Status::Obsolete);
1049 }
1050
Václav Kubernát1e09bd62020-02-17 15:13:38 +01001051 SECTION("units")
1052 {
Václav Kubernát13b23d72020-04-16 21:49:51 +02001053 yang::LeafDataType expectedType;
1054 std::optional<std::string> expectedUnits;
Václav Kubernát1e09bd62020-02-17 15:13:38 +01001055 SECTION("length")
1056 {
1057 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("length")));
Václav Kubernát13b23d72020-04-16 21:49:51 +02001058 expectedType.emplace<yang::Int32>();
1059 expectedUnits = "m";
Václav Kubernát1e09bd62020-02-17 15:13:38 +01001060 }
1061
1062 SECTION("wavelength")
1063 {
1064 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("wavelength")));
Václav Kubernát13b23d72020-04-16 21:49:51 +02001065 expectedType.emplace<yang::Decimal>();
1066 expectedUnits = "nm";
Václav Kubernát1e09bd62020-02-17 15:13:38 +01001067 }
1068
1069 SECTION("leafInt32")
1070 {
1071 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("leafInt32")));
Václav Kubernát13b23d72020-04-16 21:49:51 +02001072 expectedType.emplace<yang::Int32>();
Václav Kubernát1e09bd62020-02-17 15:13:38 +01001073 }
1074
1075 SECTION("duration")
1076 {
1077 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("duration")));
Václav Kubernát13b23d72020-04-16 21:49:51 +02001078 expectedType.emplace<yang::Int32>();
1079 expectedUnits = "s";
Václav Kubernát1e09bd62020-02-17 15:13:38 +01001080 }
1081
1082 SECTION("another-duration")
1083 {
1084 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("another-duration")));
Václav Kubernát13b23d72020-04-16 21:49:51 +02001085 expectedType.emplace<yang::Int32>();
1086 expectedUnits = "vt";
Václav Kubernát1e09bd62020-02-17 15:13:38 +01001087 }
Václav Kubernát13b23d72020-04-16 21:49:51 +02001088 REQUIRE(ys.leafType(pathToSchemaString(path, Prefixes::WhenNeeded)) == yang::TypeInfo{expectedType, expectedUnits});
Václav Kubernát1e09bd62020-02-17 15:13:38 +01001089 }
1090
1091 SECTION("nodeType")
1092 {
1093 yang::NodeTypes expected;
1094 SECTION("leafInt32")
1095 {
1096 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, leaf_("leafInt32")));
1097 expected = yang::NodeTypes::Leaf;
1098 }
1099
1100 SECTION("a")
1101 {
1102 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
1103 expected = yang::NodeTypes::Container;
1104 }
1105
1106 SECTION("a/a2/a3")
1107 {
1108 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
1109 path.m_nodes.push_back(schemaNode_(container_("a2")));
1110 path.m_nodes.push_back(schemaNode_(container_("a3")));
1111 expected = yang::NodeTypes::PresenceContainer;
1112 }
1113
1114 SECTION("_list")
1115 {
1116 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, list_("_list")));
1117 expected = yang::NodeTypes::List;
1118 }
1119
1120 REQUIRE(ys.nodeType(pathToSchemaString(path, Prefixes::WhenNeeded)) == expected);
1121 }
Václav Kubernátbd5e3c22020-02-19 15:22:00 +01001122
1123 SECTION("leafrefPath")
1124 {
1125 REQUIRE(ys.leafrefPath("/example-schema:activeNumber") == "/example-schema:_list/number");
1126 }
Václav Kubernát0599e9f2020-04-21 09:51:33 +02001127
1128 SECTION("isConfig")
1129 {
1130 REQUIRE(ys.isConfig("/example-schema:leafInt32"));
1131 REQUIRE_FALSE(ys.isConfig("/example-schema:clockSpeed"));
1132 REQUIRE_FALSE(ys.isConfig("/example-schema:systemStats"));
1133 REQUIRE_FALSE(ys.isConfig("/example-schema:systemStats/upTime"));
1134 }
Václav Kubernátbd0d5c82020-04-21 10:22:03 +02001135
Václav Kubernátb1a75c62020-04-21 15:20:16 +02001136 SECTION("defaultValue")
1137 {
1138 REQUIRE(ys.defaultValue("/example-schema:leafUint64") == "9001");
1139 REQUIRE(ys.defaultValue("/example-schema:leafEnumTypedefRestricted") == "data");
1140 REQUIRE(ys.defaultValue("/example-schema:leafInt32") == std::nullopt);
1141 }
1142
Václav Kubernátbd0d5c82020-04-21 10:22:03 +02001143 SECTION("moduleNodes")
1144 {
Václav Kubernátbd0d5c82020-04-21 10:22:03 +02001145 }
Václav Kubernát0d4db442018-07-18 17:18:43 +02001146 }
1147
1148 SECTION("negative")
1149 {
1150 SECTION("nonexistent nodes")
1151 {
1152 SECTION("example-schema:coze")
1153 {
1154 node.first = "example-schema";
1155 node.second = "coze";
1156 }
1157
1158 SECTION("example-schema:a/nevim")
1159 {
Václav Kubernát2eaceb82018-10-08 19:56:30 +02001160 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
Václav Kubernát0d4db442018-07-18 17:18:43 +02001161 node.second = "nevim";
1162 }
1163
1164 SECTION("modul:a/nevim")
1165 {
Václav Kubernát2eaceb82018-10-08 19:56:30 +02001166 path.m_nodes.push_back(schemaNode_(module_{"modul"}, container_("a")));
Václav Kubernát0d4db442018-07-18 17:18:43 +02001167 node.second = "nevim";
1168 }
1169
1170 REQUIRE(!ys.isPresenceContainer(path, node));
1171 REQUIRE(!ys.isList(path, node));
1172 REQUIRE(!ys.isLeaf(path, node));
1173 REQUIRE(!ys.isContainer(path, node));
1174 }
1175
1176 SECTION("\"is\" methods return false for existing nodes for different nodetypes")
1177 {
1178 SECTION("example-schema:a")
1179 {
1180 node.first = "example-schema";
1181 node.second = "a";
1182 }
1183
1184 SECTION("example-schema:a/a2")
1185 {
Václav Kubernát2eaceb82018-10-08 19:56:30 +02001186 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
Václav Kubernát0d4db442018-07-18 17:18:43 +02001187 node.second = "a2";
1188 }
1189
1190 REQUIRE(!ys.isPresenceContainer(path, node));
1191 REQUIRE(!ys.isList(path, node));
1192 REQUIRE(!ys.isLeaf(path, node));
1193 }
1194
1195 SECTION("nodetype-specific methods called with different nodetypes")
1196 {
Václav Kubernát2eaceb82018-10-08 19:56:30 +02001197 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
Václav Kubernát0d4db442018-07-18 17:18:43 +02001198 node.second = "a2";
1199
Václav Kubernát0d4db442018-07-18 17:18:43 +02001200 REQUIRE(!ys.listHasKey(path, node, "chacha"));
1201 }
1202
1203 SECTION("nonexistent module")
1204 {
Václav Kubernát75877de2019-11-20 17:43:02 +01001205 REQUIRE(!ys.isModule("notAModule"));
Václav Kubernát0d4db442018-07-18 17:18:43 +02001206 }
Václav Kubernáteeb38842019-03-20 19:46:05 +01001207
Václav Kubernát7d82da72019-04-11 15:16:38 +02001208 SECTION("grouping is not a node")
1209 {
1210 SECTION("example-schema:arithmeticFlags")
1211 {
1212 node.first = "example-schema";
1213 node.second = "arithmeticFlags";
1214 }
1215
1216 SECTION("example-schema:flags")
1217 {
1218 node.first = "example-schema";
1219 node.second = "startAndStop";
1220 }
1221
1222 REQUIRE(!ys.isPresenceContainer(path, node));
1223 REQUIRE(!ys.isList(path, node));
1224 REQUIRE(!ys.isLeaf(path, node));
1225 REQUIRE(!ys.isContainer(path, node));
1226 }
Václav Kubernát280df4a2019-11-01 14:46:34 +01001227
1228 SECTION("choice is not a node")
1229 {
1230 SECTION("example-schema:interface")
1231 {
1232 node.first = "example-schema";
1233 node.second = "interface";
1234 }
1235
1236 REQUIRE(!ys.isPresenceContainer(path, node));
1237 REQUIRE(!ys.isList(path, node));
1238 REQUIRE(!ys.isLeaf(path, node));
1239 REQUIRE(!ys.isContainer(path, node));
1240 }
1241
1242 SECTION("case is not a node")
1243 {
1244 SECTION("example-schema:caseLoopback")
1245 {
1246 node.first = "example-schema";
1247 node.second = "caseLoopback";
1248 }
1249
1250 SECTION("example-schema:caseEthernet")
1251 {
1252 node.first = "example-schema";
1253 node.second = "caseEthernet";
1254 }
1255
1256 REQUIRE(!ys.isPresenceContainer(path, node));
1257 REQUIRE(!ys.isList(path, node));
1258 REQUIRE(!ys.isLeaf(path, node));
1259 REQUIRE(!ys.isContainer(path, node));
1260 }
Václav Kubernát0d4db442018-07-18 17:18:43 +02001261 }
1262}