blob: d9c2a89472c3a21a2dd24031442824de8b6d0250 [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>
Jan Kundráta33cf082019-03-28 11:55:57 +010010#include "trompeloeil_doctest.h"
Václav Kubernát0d4db442018-07-18 17:18:43 +020011#include "yang_schema.hpp"
12
Václav Kubernát4f77a252019-02-19 16:51:30 +010013const char* second_schema = R"(
14module second-schema {
15 namespace "http://example.com/nevim";
16 prefix second;
17
18 import example-schema {
19 prefix "example";
20 }
21
Václav Kubernáteeb38842019-03-20 19:46:05 +010022 identity pineapple {
23 base "example:fruit";
24 }
25
Václav Kubernát4f77a252019-02-19 16:51:30 +010026 augment /example:a {
27 container augmentedContainer {
28 }
29 }
30
31 container bla {
32 container bla2 {
33 }
34 }
35}
36)";
37
38const char* example_schema = R"(
Václav Kubernát0d4db442018-07-18 17:18:43 +020039module example-schema {
Václav Kubernát6a713d62018-10-03 18:47:34 +020040 yang-version 1.1;
Václav Kubernát0d4db442018-07-18 17:18:43 +020041 namespace "http://example.com/example-sports";
42 prefix coze;
43
Václav Kubernáteeb38842019-03-20 19:46:05 +010044 identity drink {
45 }
46
47 identity voda {
48 base "drink";
49 }
50
51 identity food {
52 }
53
54 identity fruit {
55 base "food";
56 }
57
58 identity pizza {
59 base "food";
60 }
61
62 identity hawaii {
63 base "pizza";
64 }
65
Václav Kubernát0d4db442018-07-18 17:18:43 +020066 container a {
67 container a2 {
68 container a3 {
69 presence true;
70 }
71 }
72
73 leaf leafa {
74 type string;
75 }
76 }
77
78 container b {
79 container b2 {
80 presence true;
81 container b3 {
82 }
83 }
84 }
85
86 leaf leafString {
87 type string;
88 }
89
90 leaf leafDecimal {
91 type decimal64 {
92 fraction-digits 5;
93 }
94 }
95
96 leaf leafBool {
97 type boolean;
98 }
99
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200100 leaf leafInt8 {
101 type int8;
102 }
103
104 leaf leafUint8 {
105 type uint8;
106 }
107
108 leaf leafInt16 {
109 type int16;
110 }
111
112 leaf leafUint16 {
113 type uint16;
114 }
115
116 leaf leafInt32 {
Václav Kubernát0d4db442018-07-18 17:18:43 +0200117 type int32;
118 }
119
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200120 leaf leafUint32 {
Václav Kubernát0d4db442018-07-18 17:18:43 +0200121 type uint32;
122 }
123
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200124 leaf leafInt64 {
125 type int64;
126 }
127
128 leaf leafUint64 {
129 type uint64;
130 }
131
Václav Kubernát0d4db442018-07-18 17:18:43 +0200132 leaf leafEnum {
133 type enumeration {
134 enum lol;
135 enum data;
136 enum coze;
137 }
138 }
139
Václav Kubernát6a713d62018-10-03 18:47:34 +0200140 typedef enumTypedef {
141 type enumeration {
142 enum lol;
143 enum data;
144 enum coze;
145 }
146 }
147
148 typedef enumTypedefRestricted {
149 type enumTypedef {
150 enum lol;
151 enum data;
152 }
153 }
154
155 leaf leafEnumTypedef {
156 type enumTypedef;
157 }
158
159 leaf leafEnumTypedefRestricted {
160 type enumTypedef {
161 enum data;
162 enum coze;
163 }
164 }
165
166 leaf leafEnumTypedefRestricted2 {
167 type enumTypedefRestricted;
168 }
169
Václav Kubernáteeb38842019-03-20 19:46:05 +0100170 leaf foodIdentLeaf {
171 type identityref {
172 base "food";
173 }
174 }
175
176 leaf pizzaIdentLeaf {
177 type identityref {
178 base "pizza";
179 }
180 }
181
182 leaf foodDrinkIdentLeaf {
183 type identityref {
184 base "food";
185 base "drink";
186 }
187 }
188
Václav Kubernát0d4db442018-07-18 17:18:43 +0200189 list _list {
190 key number;
191
192 leaf number {
193 type int32;
194 }
195
196 container contInList {
197 presence true;
198 }
199 }
200
201 list twoKeyList {
202 key "name number";
203
204 leaf number {
205 type int32;
206 }
207
208 leaf name {
209 type string;
210 }
211 }
Václav Kubernát7d82da72019-04-11 15:16:38 +0200212
213 grouping arithmeticFlags {
214 leaf carry {
215 type boolean;
216 }
217 leaf zero {
218 type boolean;
219 }
220 }
221
222 grouping flags {
223 leaf direction {
224 type boolean;
225 }
226 leaf interrupt {
227 type boolean;
228 }
229
230 uses arithmeticFlags;
231 }
232
233 uses flags;
Václav Kubernát280df4a2019-11-01 14:46:34 +0100234
235 choice interface {
236 case caseLoopback {
237 container loopback {
238 leaf ip {
239 type string;
240 }
241 }
242 }
243
244 case caseEthernet {
245 container ethernet {
246 leaf ip {
247 type string;
248 }
249 }
250 }
251 }
252
Václav Kubernát0d4db442018-07-18 17:18:43 +0200253})";
254
Václav Kubernát47a3f672019-11-08 15:42:43 +0100255namespace std {
256std::ostream& operator<<(std::ostream& s, const std::set<std::string> set)
257{
258 s << std::endl << "{";
259 std::copy(set.begin(), set.end(), std::experimental::make_ostream_joiner(s, ", "));
260 s << "}" << std::endl;
261 return s;
262}
263}
264
Václav Kubernát0d4db442018-07-18 17:18:43 +0200265TEST_CASE("yangschema")
266{
Václav Kubernát4f77a252019-02-19 16:51:30 +0100267 using namespace std::string_view_literals;
Václav Kubernát0d4db442018-07-18 17:18:43 +0200268 YangSchema ys;
Václav Kubernát4f77a252019-02-19 16:51:30 +0100269 ys.registerModuleCallback([]([[maybe_unused]] auto modName, auto, auto) {
270 assert("example-schema"sv == modName);
271 return example_schema;
272 });
273 ys.addSchemaString(second_schema);
274
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200275 schemaPath_ path;
Václav Kubernát0d4db442018-07-18 17:18:43 +0200276 ModuleNodePair node;
277
278 SECTION("positive")
279 {
280 SECTION("isContainer")
281 {
282 SECTION("example-schema:a")
283 {
284 node.first = "example-schema";
285 node.second = "a";
286 }
287
288 SECTION("example-schema:a/a2")
289 {
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200290 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
Václav Kubernát0d4db442018-07-18 17:18:43 +0200291 node.second = "a2";
292 }
293
Václav Kubernát280df4a2019-11-01 14:46:34 +0100294 SECTION("example-schema:ethernet")
295 {
296 node.first = "example-schema";
297 node.second = "ethernet";
298 }
299
300 SECTION("example-schema:loopback")
301 {
302 node.first = "example-schema";
303 node.second = "loopback";
304 }
305
Václav Kubernát0d4db442018-07-18 17:18:43 +0200306 REQUIRE(ys.isContainer(path, node));
307 }
308 SECTION("isLeaf")
309 {
310 SECTION("example-schema:leafString")
311 {
312 node.first = "example-schema";
313 node.second = "leafString";
314 }
315
316 SECTION("example-schema:a/leafa")
317 {
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200318 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
Václav Kubernát0d4db442018-07-18 17:18:43 +0200319 node.first = "example-schema";
320 node.second = "leafa";
321 }
322
Václav Kubernát7d82da72019-04-11 15:16:38 +0200323 SECTION("example-schema:carry")
324 {
325 node.first = "example-schema";
326 node.second = "carry";
327 }
328
329 SECTION("example-schema:zero")
330 {
331 node.first = "example-schema";
332 node.second = "zero";
333 }
334
335 SECTION("example-schema:direction")
336 {
337 node.first = "example-schema";
338 node.second = "direction";
339 }
340
341 SECTION("example-schema:interrupt")
342 {
343 node.first = "example-schema";
344 node.second = "interrupt";
345 }
346
Václav Kubernát0d4db442018-07-18 17:18:43 +0200347 REQUIRE(ys.isLeaf(path, node));
348 }
349 SECTION("isModule")
350 {
351 REQUIRE(ys.isModule(path, "example-schema"));
352 }
353 SECTION("isList")
354 {
355 SECTION("example-schema:_list")
356 {
357 node.first = "example-schema";
358 node.second = "_list";
359 }
360
361 SECTION("example-schema:twoKeyList")
362 {
363 node.first = "example-schema";
364 node.second = "twoKeyList";
365 }
366
367 REQUIRE(ys.isList(path, node));
368 }
369 SECTION("isPresenceContainer")
370 {
371 SECTION("example-schema:a/a2/a3")
372 {
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200373 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
374 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a2")));
Václav Kubernát0d4db442018-07-18 17:18:43 +0200375 node.second = "a3";
376 }
377
378 REQUIRE(ys.isPresenceContainer(path, node));
379 }
380 SECTION("leafEnumHasValue")
381 {
Václav Kubernát0d4db442018-07-18 17:18:43 +0200382 std::string value;
Václav Kubernát6a713d62018-10-03 18:47:34 +0200383 SECTION("leafEnum")
384 {
385 node.first = "example-schema";
386 node.second = "leafEnum";
Václav Kubernát0d4db442018-07-18 17:18:43 +0200387
Václav Kubernát6a713d62018-10-03 18:47:34 +0200388 SECTION("lol")
389 value = "lol";
Václav Kubernát0d4db442018-07-18 17:18:43 +0200390
Václav Kubernát6a713d62018-10-03 18:47:34 +0200391 SECTION("data")
392 value = "data";
Václav Kubernát0d4db442018-07-18 17:18:43 +0200393
Václav Kubernát6a713d62018-10-03 18:47:34 +0200394 SECTION("coze")
395 value = "coze";
396 }
397
398 SECTION("leafEnumTypedef")
399 {
400 node.first = "example-schema";
401 node.second = "leafEnumTypedef";
402
403 SECTION("lol")
404 value = "lol";
405
406 SECTION("data")
407 value = "data";
408
409 SECTION("coze")
410 value = "coze";
411 }
412
413 SECTION("leafEnumTypedefRestricted")
414 {
415 node.first = "example-schema";
416 node.second = "leafEnumTypedefRestricted";
417
418 SECTION("data")
419 value = "data";
420
421 SECTION("coze")
422 value = "coze";
423 }
424
425 SECTION("leafEnumTypedefRestricted2")
426 {
427 node.first = "example-schema";
428 node.second = "leafEnumTypedefRestricted2";
429
430 SECTION("lol")
431 value = "lol";
432
433 SECTION("data")
434 value = "data";
435 }
Václav Kubernát0d4db442018-07-18 17:18:43 +0200436
437 REQUIRE(ys.leafEnumHasValue(path, node, value));
438 }
Václav Kubernáteeb38842019-03-20 19:46:05 +0100439 SECTION("leafIdentityIsValid")
440 {
441 ModuleValuePair value;
442
443 SECTION("foodIdentLeaf")
444 {
445 node.first = "example-schema";
446 node.second = "foodIdentLeaf";
447
448 SECTION("food")
449 {
450 value.second = "food";
451 }
452 SECTION("example-schema:food")
453 {
454 value.first = "example-schema";
455 value.second = "food";
456 }
457 SECTION("pizza")
458 {
459 value.second = "pizza";
460 }
461 SECTION("example-schema:pizza")
462 {
463 value.first = "example-schema";
464 value.second = "pizza";
465 }
466 SECTION("hawaii")
467 {
468 value.second = "hawaii";
469 }
470 SECTION("example-schema:hawaii")
471 {
472 value.first = "example-schema";
473 value.second = "hawaii";
474 }
475 SECTION("fruit")
476 {
477 value.second = "fruit";
478 }
479 SECTION("example-schema:fruit")
480 {
481 value.first = "example-schema";
482 value.second = "fruit";
483 }
484 SECTION("second-schema:pineapple")
485 {
486 value.first = "second-schema";
487 value.second = "pineapple";
488 }
489 }
490
491 SECTION("pizzaIdentLeaf")
492 {
493 node.first = "example-schema";
494 node.second = "pizzaIdentLeaf";
495
496 SECTION("pizza")
497 {
498 value.second = "pizza";
499 }
500 SECTION("example-schema:pizza")
501 {
502 value.first = "example-schema";
503 value.second = "pizza";
504 }
505 SECTION("hawaii")
506 {
507 value.second = "hawaii";
508 }
509 SECTION("example-schema:hawaii")
510 {
511 value.first = "example-schema";
512 value.second = "hawaii";
513 }
514 }
515
516 SECTION("foodDrinkIdentLeaf")
517 {
518 node.first = "example-schema";
519 node.second = "foodDrinkIdentLeaf";
520
521 SECTION("food")
522 {
523 value.second = "food";
524 }
525 SECTION("example-schema:food")
526 {
527 value.first = "example-schema";
528 value.second = "food";
529 }
530 SECTION("drink")
531 {
532 value.second = "drink";
533 }
534 SECTION("example-schema:drink")
535 {
536 value.first = "example-schema";
537 value.second = "drink";
538 }
539 }
540 REQUIRE(ys.leafIdentityIsValid(path, node, value));
541 }
542
Václav Kubernát0d4db442018-07-18 17:18:43 +0200543 SECTION("listHasKey")
544 {
545 std::string key;
546
547 SECTION("_list")
548 {
549 node.first = "example-schema";
550 node.second = "_list";
551 SECTION("number")
552 key = "number";
553 }
554
555 SECTION("twoKeyList")
556 {
557 node.first = "example-schema";
558 node.second = "twoKeyList";
559 SECTION("number")
560 key = "number";
561 SECTION("name")
562 key = "name";
563 }
564
565 REQUIRE(ys.listHasKey(path, node, key));
566 }
567 SECTION("listKeys")
568 {
569 std::set<std::string> set;
570
571 SECTION("_list")
572 {
573 set = {"number"};
574 node.first = "example-schema";
575 node.second = "_list";
576 }
577
578 SECTION("twoKeyList")
579 {
580 set = {"number", "name"};
581 node.first = "example-schema";
582 node.second = "twoKeyList";
583 }
584
585 REQUIRE(ys.listKeys(path, node) == set);
586 }
587 SECTION("leafType")
588 {
589 yang::LeafDataTypes type;
590
591 SECTION("leafString")
592 {
593 node.first = "example-schema";
594 node.second = "leafString";
595 type = yang::LeafDataTypes::String;
596 }
597
598 SECTION("leafDecimal")
599 {
600 node.first = "example-schema";
601 node.second = "leafDecimal";
602 type = yang::LeafDataTypes::Decimal;
603 }
604
605 SECTION("leafBool")
606 {
607 node.first = "example-schema";
608 node.second = "leafBool";
609 type = yang::LeafDataTypes::Bool;
610 }
611
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200612 SECTION("leafInt8")
Václav Kubernát0d4db442018-07-18 17:18:43 +0200613 {
614 node.first = "example-schema";
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200615 node.second = "leafInt8";
616 type = yang::LeafDataTypes::Int8;
Václav Kubernát0d4db442018-07-18 17:18:43 +0200617 }
618
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200619 SECTION("leafUint8")
Václav Kubernát0d4db442018-07-18 17:18:43 +0200620 {
621 node.first = "example-schema";
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200622 node.second = "leafUint8";
623 type = yang::LeafDataTypes::Uint8;
624 }
625
626 SECTION("leafInt15")
627 {
628 node.first = "example-schema";
629 node.second = "leafInt16";
630 type = yang::LeafDataTypes::Int16;
631 }
632
633 SECTION("leafUint16")
634 {
635 node.first = "example-schema";
636 node.second = "leafUint16";
637 type = yang::LeafDataTypes::Uint16;
638 }
639
640 SECTION("leafInt32")
641 {
642 node.first = "example-schema";
643 node.second = "leafInt32";
644 type = yang::LeafDataTypes::Int32;
645 }
646
647 SECTION("leafUint32")
648 {
649 node.first = "example-schema";
650 node.second = "leafUint32";
651 type = yang::LeafDataTypes::Uint32;
652 }
653
654 SECTION("leafInt64")
655 {
656 node.first = "example-schema";
657 node.second = "leafInt64";
658 type = yang::LeafDataTypes::Int64;
659 }
660
661 SECTION("leafUint64")
662 {
663 node.first = "example-schema";
664 node.second = "leafUint64";
665 type = yang::LeafDataTypes::Uint64;
Václav Kubernát0d4db442018-07-18 17:18:43 +0200666 }
667
668 SECTION("leafEnum")
669 {
670 node.first = "example-schema";
671 node.second = "leafEnum";
672 type = yang::LeafDataTypes::Enum;
673 }
674
675 REQUIRE(ys.leafType(path, node) == type);
676 }
677 SECTION("childNodes")
678 {
679 std::set<std::string> set;
680
681 SECTION("<root>")
682 {
683 set = {"example-schema:a", "example-schema:b", "example-schema:leafString",
Ivona Oboňová88c78ca2019-07-02 18:40:07 +0200684 "example-schema:leafDecimal", "example-schema:leafBool",
685 "example-schema:leafInt8", "example-schema:leafUint8",
686 "example-schema:leafInt16", "example-schema:leafUint16",
687 "example-schema:leafInt32", "example-schema:leafUint32",
688 "example-schema:leafInt64", "example-schema:leafUint64",
689 "example-schema:leafEnum", "example-schema:leafEnumTypedef",
Václav Kubernát6a713d62018-10-03 18:47:34 +0200690 "example-schema:leafEnumTypedefRestricted", "example-schema:leafEnumTypedefRestricted2",
Václav Kubernáteeb38842019-03-20 19:46:05 +0100691 "example-schema:foodIdentLeaf", "example-schema:pizzaIdentLeaf", "example-schema:foodDrinkIdentLeaf",
Václav Kubernát7d82da72019-04-11 15:16:38 +0200692 "example-schema:_list", "example-schema:twoKeyList", "second-schema:bla",
693 "example-schema:carry", "example-schema:zero", "example-schema:direction",
Václav Kubernát280df4a2019-11-01 14:46:34 +0100694 "example-schema:interrupt",
695 "example-schema:ethernet", "example-schema:loopback"};
Václav Kubernát0d4db442018-07-18 17:18:43 +0200696 }
697
Václav Kubernát4f77a252019-02-19 16:51:30 +0100698 SECTION("example-schema:a")
Václav Kubernát0d4db442018-07-18 17:18:43 +0200699 {
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200700 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
Václav Kubernát4f77a252019-02-19 16:51:30 +0100701 set = {"a2", "leafa", "second-schema:augmentedContainer"};
702 }
703
704 SECTION("second-schema:bla")
705 {
706 path.m_nodes.push_back(schemaNode_(module_{"second-schema"}, container_("bla")));
707 set = {"bla2"};
Václav Kubernát0d4db442018-07-18 17:18:43 +0200708 }
709
Václav Kubernát47a3f672019-11-08 15:42:43 +0100710 SECTION("example-schema:ethernet")
711 {
712 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("ethernet")));
713 set = {"ip"};
714 }
715
Václav Kubernáte7d4aea2018-09-11 18:15:48 +0200716 REQUIRE(ys.childNodes(path, Recursion::NonRecursive) == set);
Václav Kubernát0d4db442018-07-18 17:18:43 +0200717 }
718 }
719
720 SECTION("negative")
721 {
722 SECTION("nonexistent nodes")
723 {
724 SECTION("example-schema:coze")
725 {
726 node.first = "example-schema";
727 node.second = "coze";
728 }
729
730 SECTION("example-schema:a/nevim")
731 {
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200732 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
Václav Kubernát0d4db442018-07-18 17:18:43 +0200733 node.second = "nevim";
734 }
735
736 SECTION("modul:a/nevim")
737 {
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200738 path.m_nodes.push_back(schemaNode_(module_{"modul"}, container_("a")));
Václav Kubernát0d4db442018-07-18 17:18:43 +0200739 node.second = "nevim";
740 }
741
742 REQUIRE(!ys.isPresenceContainer(path, node));
743 REQUIRE(!ys.isList(path, node));
744 REQUIRE(!ys.isLeaf(path, node));
745 REQUIRE(!ys.isContainer(path, node));
746 }
747
748 SECTION("\"is\" methods return false for existing nodes for different nodetypes")
749 {
750 SECTION("example-schema:a")
751 {
752 node.first = "example-schema";
753 node.second = "a";
754 }
755
756 SECTION("example-schema:a/a2")
757 {
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200758 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
Václav Kubernát0d4db442018-07-18 17:18:43 +0200759 node.second = "a2";
760 }
761
762 REQUIRE(!ys.isPresenceContainer(path, node));
763 REQUIRE(!ys.isList(path, node));
764 REQUIRE(!ys.isLeaf(path, node));
765 }
766
767 SECTION("nodetype-specific methods called with different nodetypes")
768 {
Václav Kubernát2eaceb82018-10-08 19:56:30 +0200769 path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
Václav Kubernát0d4db442018-07-18 17:18:43 +0200770 node.second = "a2";
771
772 REQUIRE(!ys.leafEnumHasValue(path, node, "haha"));
773 REQUIRE(!ys.listHasKey(path, node, "chacha"));
774 }
775
776 SECTION("nonexistent module")
777 {
778 REQUIRE(!ys.isModule(path, "notAModule"));
779 }
Václav Kubernáteeb38842019-03-20 19:46:05 +0100780
781 SECTION("leafIdentityIsValid")
782 {
783 ModuleValuePair value;
784 SECTION("pizzaIdentLeaf")
785 {
786 node.first = "example-schema";
787 node.second = "pizzaIdentLeaf";
788
789 SECTION("wrong base ident")
790 {
791 SECTION("food")
792 {
793 value.second = "food";
794 }
795 SECTION("fruit")
796 {
797 value.second = "fruit";
798 }
799 }
800 SECTION("non-existent identity")
801 {
802 value.second = "nonexistent";
803 }
804 SECTION("weird module")
805 {
806 value.first = "ahahaha";
807 value.second = "pizza";
808 }
809 }
810 SECTION("different module identity, but withotu prefix")
811 {
812 node.first = "example-schema";
813 node.second = "foodIdentLeaf";
814 value.second = "pineapple";
815 }
816 REQUIRE_FALSE(ys.leafIdentityIsValid(path, node, value));
817 }
Václav Kubernát7d82da72019-04-11 15:16:38 +0200818
819 SECTION("grouping is not a node")
820 {
821 SECTION("example-schema:arithmeticFlags")
822 {
823 node.first = "example-schema";
824 node.second = "arithmeticFlags";
825 }
826
827 SECTION("example-schema:flags")
828 {
829 node.first = "example-schema";
830 node.second = "startAndStop";
831 }
832
833 REQUIRE(!ys.isPresenceContainer(path, node));
834 REQUIRE(!ys.isList(path, node));
835 REQUIRE(!ys.isLeaf(path, node));
836 REQUIRE(!ys.isContainer(path, node));
837 }
Václav Kubernát280df4a2019-11-01 14:46:34 +0100838
839 SECTION("choice is not a node")
840 {
841 SECTION("example-schema:interface")
842 {
843 node.first = "example-schema";
844 node.second = "interface";
845 }
846
847 REQUIRE(!ys.isPresenceContainer(path, node));
848 REQUIRE(!ys.isList(path, node));
849 REQUIRE(!ys.isLeaf(path, node));
850 REQUIRE(!ys.isContainer(path, node));
851 }
852
853 SECTION("case is not a node")
854 {
855 SECTION("example-schema:caseLoopback")
856 {
857 node.first = "example-schema";
858 node.second = "caseLoopback";
859 }
860
861 SECTION("example-schema:caseEthernet")
862 {
863 node.first = "example-schema";
864 node.second = "caseEthernet";
865 }
866
867 REQUIRE(!ys.isPresenceContainer(path, node));
868 REQUIRE(!ys.isList(path, node));
869 REQUIRE(!ys.isLeaf(path, node));
870 REQUIRE(!ys.isContainer(path, node));
871 }
Václav Kubernát0d4db442018-07-18 17:18:43 +0200872 }
873}