blob: 02a24d34966ceeefb2d3bdf3d9d5cef2d5168cfe [file] [log] [blame]
FredGand944bdc2019-11-05 21:57:07 +08001/*
2 * @file test_printer_yin.c
3 * @author: Fred Gan <ganshaolong@vip.qq.com>
4 * @brief unit tests for functions from printer_yin.c
5 *
Radek Iša56ca9e42020-09-08 18:42:00 +02006 * Copyright (c) 2019-2020 CESNET, z.s.p.o.
FredGand944bdc2019-11-05 21:57:07 +08007 *
8 * This source code is licensed under BSD 3-Clause License (the "License").
9 * You may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * https://opensource.org/licenses/BSD-3-Clause
13 */
Radek Iša56ca9e42020-09-08 18:42:00 +020014#define _UTEST_MAIN_
15#include "utests.h"
FredGand944bdc2019-11-05 21:57:07 +080016
Michal Vasko7c8439f2020-08-05 13:25:19 +020017#include "common.h"
Radek Krejci70593c12020-06-13 20:48:09 +020018#include "context.h"
Michal Vaskoafac7822020-10-20 14:22:26 +020019#include "out.h"
Radek Krejci70593c12020-06-13 20:48:09 +020020#include "printer_schema.h"
Michal Vasko7c8439f2020-08-05 13:25:19 +020021#include "tree_schema.h"
FredGand944bdc2019-11-05 21:57:07 +080022
FredGand944bdc2019-11-05 21:57:07 +080023static void
24test_module(void **state)
25{
Michal Vasko4de7d072021-07-09 09:13:18 +020026 struct lys_module *mod;
FredGand944bdc2019-11-05 21:57:07 +080027
Michal Vasko22e0f3a2021-09-22 12:19:23 +020028 char *orig = malloc(8096);
29
30 strcpy(orig,
FredGand944bdc2019-11-05 21:57:07 +080031 "module all {\n"
32 " yang-version 1.1;\n"
33 " namespace \"urn:all\";\n"
34 " prefix all_mod;\n\n"
35 " import ietf-yang-types {\n"
36 " prefix yt;\n"
37 " revision-date 2013-07-15;\n"
38 " description\n"
39 " \"YANG types\";\n"
40 " reference\n"
41 " \"RFC reference\";\n"
42 " }\n\n"
43 " feature feat1 {\n"
44 " if-feature \"feat2\";\n"
45 " status obsolete;\n"
46 " }\n\n"
47 " feature feat2;\n"
48 " feature feat3;\n\n"
49 " identity ident2 {\n"
50 " base ident1;\n"
51 " }\n\n"
52 " identity ident1;\n\n"
53 " typedef tdef1 {\n"
54 " type tdef2 {\n"
55 " length \"3..9 | 30..40\";\n"
56 " pattern \"[ac]*\";\n"
57 " }\n"
58 " units \"none\";\n"
59 " default \"aaa\";\n"
60 " }\n\n"
61 " typedef tdef2 {\n"
62 " type string {\n"
63 " length \"2..10 | 20..50\";\n"
64 " pattern \"[ab]*\";\n"
65 " }\n"
66 " }\n\n"
67 " grouping group1 {\n"
68 " leaf leaf1 {\n"
69 " type int8;\n"
70 " }\n"
71 " }\n\n"
72 " container cont1 {\n"
73 " leaf leaf2 {\n"
74 " if-feature \"feat1\";\n"
75 " type int16;\n"
76 " status obsolete;\n"
77 " }\n\n"
78 " uses group1 {\n"
79 " if-feature \"feat2\";\n"
80 " refine \"leaf1\" {\n"
81 " if-feature \"feat3\";\n"
82 " must \"24 - 4 = number('20')\";\n"
83 " default \"25\";\n"
84 " config true;\n"
85 " mandatory false;\n"
86 " description\n"
87 " \"dsc\";\n"
88 " reference\n"
89 " \"none\";\n"
90 " }\n"
91 " }\n\n"
92 " leaf leaf3 {\n"
93 " type int32;\n"
94 " }\n\n"
95 " leaf leaf4 {\n"
96 " type int64 {\n"
97 " range \"1000 .. 50000\" {\n"
98 " error-message\n"
99 " \"Special error message.\";\n"
100 " error-app-tag \"special-tag\";\n"
101 " }\n"
102 " }\n"
103 " }\n\n"
104 " leaf leaf5 {\n"
105 " type uint8;\n"
106 " }\n\n"
107 " leaf leaf6 {\n"
108 " type uint16;\n"
109 " }\n\n"
110 " leaf leaf7 {\n"
111 " type uint32;\n"
112 " }\n\n"
113 " leaf leaf8 {\n"
114 " type uint64;\n"
115 " }\n\n"
116 " choice choic1 {\n"
117 " default \"leaf9b\";\n"
118 " leaf leaf9a {\n"
119 " type decimal64 {\n"
120 " fraction-digits 9;\n"
121 " }\n"
122 " }\n\n"
123 " leaf leaf9b {\n"
124 " type boolean;\n"
125 " default \"false\";\n"
126 " }\n"
127 " }\n\n"
128 " leaf leaf10 {\n"
129 " type boolean;\n"
Michal Vasko22e0f3a2021-09-22 12:19:23 +0200130 " }\n\n");
131 strcpy(orig + strlen(orig),
FredGand944bdc2019-11-05 21:57:07 +0800132 " leaf leaf11 {\n"
133 " type enumeration {\n"
134 " enum \"one\";\n"
135 " enum \"two\";\n"
136 " enum \"five\" {\n"
137 " value 5;\n"
138 " }\n"
139 " }\n"
140 " }\n\n"
141 " leaf leaf12 {\n"
142 " type bits {\n"
143 " bit flag0 {\n"
144 " position 0;\n"
145 " }\n"
146 " bit flag1;\n"
147 " bit flag2 {\n"
148 " position 2;\n"
149 " }\n"
150 " bit flag3 {\n"
151 " position 3;\n"
152 " }\n"
153 " }\n"
154 " default \"flag0 flag3\";\n"
155 " }\n\n"
156 " leaf leaf13 {\n"
157 " type binary;\n"
158 " }\n\n"
159 " leaf leaf14 {\n"
160 " type leafref {\n"
161 " path \"/cont1/leaf17\";\n"
162 " }\n"
163 " }\n\n"
164 " leaf leaf15 {\n"
165 " type empty;\n"
166 " }\n\n"
167 " leaf leaf16 {\n"
168 " type union {\n"
169 " type instance-identifier {\n"
170 " require-instance true;\n"
171 " }\n"
172 " type int8;\n"
173 " }\n"
174 " }\n\n"
175 " list list1 {\n"
176 " key \"leaf18\";\n"
177 " unique \"leaf19\";\n"
178 " min-elements 1;\n"
179 " max-elements 20;\n"
180 " leaf leaf18 {\n"
181 " type string;\n"
182 " }\n\n"
183 " leaf leaf19 {\n"
184 " type uint32;\n"
185 " }\n\n"
186 " anyxml axml1;\n"
187 " anydata adata1;\n\n"
188 " action act1 {\n"
189 " input {\n"
190 " leaf leaf24 {\n"
191 " type string;\n"
192 " }\n"
193 " }\n\n"
194 " output {\n"
195 " leaf leaf25 {\n"
196 " type string;\n"
197 " }\n"
198 " }\n"
199 " }\n\n"
200 " notification notif1 {\n"
201 " leaf leaf26 {\n"
202 " type string;\n"
203 " }\n"
204 " }\n"
205 " }\n\n"
206 " leaf-list llist1 {\n"
207 " type tdef1;\n"
208 " ordered-by user;\n"
209 " }\n\n"
210 " list list2 {\n"
211 " key \"leaf27 leaf28\";\n"
212 " leaf leaf27 {\n"
213 " type uint8;\n"
214 " }\n\n"
215 " leaf leaf28 {\n"
216 " type uint8;\n"
217 " }\n"
218 " }\n\n"
219 " leaf leaf29 {\n"
220 " type instance-identifier;\n"
221 " }\n\n"
222 " container must-deviations-container {\n"
223 " presence \"Allows deviations on the leaf\";\n"
224 " leaf leaf30 {\n"
225 " type string;\n"
226 " }\n"
227 " }\n\n"
228 " leaf leaf23 {\n"
229 " type empty;\n"
230 " }\n"
231 " }\n\n"
232 " augment \"/cont1\" {\n"
233 " leaf leaf17 {\n"
234 " type string;\n"
235 " }\n"
236 " }\n\n"
237 " rpc rpc1 {\n"
238 " input {\n"
239 " leaf leaf20 {\n"
240 " type tdef1;\n"
241 " }\n"
242 " }\n\n"
243 " output {\n"
244 " container cont2 {\n"
245 " leaf leaf21 {\n"
246 " type empty;\n"
247 " }\n"
248 " }\n"
249 " }\n"
250 " }\n\n"
251 " container test-when {\n"
252 " leaf when-check {\n"
253 " type boolean;\n"
254 " }\n\n"
255 " leaf gated-data {\n"
256 " when \"../when-check = 'true'\";\n"
257 " type uint16;\n"
258 " }\n"
259 " }\n\n"
260 " extension c-define {\n"
261 " description\n"
262 " \"Takes as an argument a name string.\n"
263 " Makes the code generator use the given name\n"
264 " in the #define.\";\n"
265 " argument \"name\";\n"
266 " }\n"
Michal Vasko22e0f3a2021-09-22 12:19:23 +0200267 "}\n");
FredGand944bdc2019-11-05 21:57:07 +0800268
Michal Vasko22e0f3a2021-09-22 12:19:23 +0200269 char *ori_res = malloc(8096);
270
271 strcpy(ori_res,
FredGand944bdc2019-11-05 21:57:07 +0800272 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
273 "<module name=\"all\"\n"
274 " xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"\n"
275 " xmlns:all_mod=\"urn:all\"\n"
276 " xmlns:yt=\"urn:ietf:params:xml:ns:yang:ietf-yang-types\">\n"
277 " <yang-version value=\"1.1\"/>\n"
278 " <namespace uri=\"urn:all\"/>\n"
279 " <prefix value=\"all_mod\"/>\n"
280 " <import module=\"ietf-yang-types\">\n"
281 " <prefix value=\"yt\"/>\n"
282 " <revision-date date=\"2013-07-15\"/>\n"
283 " <description>\n"
284 " <text>YANG types</text>\n"
285 " </description>\n"
286 " <reference>\n"
287 " <text>RFC reference</text>\n"
288 " </reference>\n"
289 " </import>\n\n"
290 " <extension name=\"c-define\">\n"
291 " <argument name=\"name\"/>\n"
292 " <description>\n"
293 " <text>Takes as an argument a name string.\n"
294 "Makes the code generator use the given name\n"
295 "in the #define.</text>\n"
296 " </description>\n"
297 " </extension>\n"
298 " <feature name=\"feat1\">\n"
299 " <if-feature name=\"feat2\"/>\n"
300 " <status value=\"obsolete\"/>\n"
301 " </feature>\n"
302 " <feature name=\"feat2\"/>\n"
303 " <feature name=\"feat3\"/>\n"
304 " <identity name=\"ident2\">\n"
305 " <base name=\"ident1\"/>\n"
306 " </identity>\n"
307 " <identity name=\"ident1\"/>\n"
308 " <typedef name=\"tdef1\">\n"
309 " <type name=\"tdef2\">\n"
310 " <length value=\"3..9 | 30..40\"/>\n"
311 " <pattern value=\"[ac]*\"/>\n"
312 " </type>\n"
313 " <units name=\"none\"/>\n"
314 " <default value=\"aaa\"/>\n"
315 " </typedef>\n"
316 " <typedef name=\"tdef2\">\n"
317 " <type name=\"string\">\n"
318 " <length value=\"2..10 | 20..50\"/>\n"
319 " <pattern value=\"[ab]*\"/>\n"
320 " </type>\n"
321 " </typedef>\n"
322 " <grouping name=\"group1\">\n"
323 " <leaf name=\"leaf1\">\n"
324 " <type name=\"int8\"/>\n"
325 " </leaf>\n"
326 " </grouping>\n"
327 " <container name=\"cont1\">\n"
328 " <leaf name=\"leaf2\">\n"
329 " <if-feature name=\"feat1\"/>\n"
330 " <type name=\"int16\"/>\n"
331 " <status value=\"obsolete\"/>\n"
332 " </leaf>\n"
333 " <uses name=\"group1\">\n"
334 " <if-feature name=\"feat2\"/>\n"
335 " <refine target-node=\"leaf1\">\n"
336 " <if-feature name=\"feat3\"/>\n"
337 " <must condition=\"24 - 4 = number('20')\"/>\n"
338 " <default value=\"25\"/>\n"
339 " <config value=\"true\"/>\n"
340 " <mandatory value=\"false\"/>\n"
341 " <description>\n"
342 " <text>dsc</text>\n"
343 " </description>\n"
344 " <reference>\n"
345 " <text>none</text>\n"
346 " </reference>\n"
347 " </refine>\n"
348 " </uses>\n"
349 " <leaf name=\"leaf3\">\n"
350 " <type name=\"int32\"/>\n"
351 " </leaf>\n"
352 " <leaf name=\"leaf4\">\n"
353 " <type name=\"int64\">\n"
354 " <range value=\"1000 .. 50000\">\n"
355 " <error-message>\n"
356 " <value>Special error message.</value>\n"
357 " </error-message>\n"
358 " <error-app-tag value=\"special-tag\"/>\n"
359 " </range>\n"
360 " </type>\n"
361 " </leaf>\n"
362 " <leaf name=\"leaf5\">\n"
363 " <type name=\"uint8\"/>\n"
364 " </leaf>\n"
365 " <leaf name=\"leaf6\">\n"
366 " <type name=\"uint16\"/>\n"
367 " </leaf>\n"
368 " <leaf name=\"leaf7\">\n"
369 " <type name=\"uint32\"/>\n"
370 " </leaf>\n"
371 " <leaf name=\"leaf8\">\n"
372 " <type name=\"uint64\"/>\n"
373 " </leaf>\n"
374 " <choice name=\"choic1\">\n"
375 " <default value=\"leaf9b\"/>\n"
376 " <leaf name=\"leaf9a\">\n"
377 " <type name=\"decimal64\">\n"
378 " <fraction-digits value=\"9\"/>\n"
379 " </type>\n"
380 " </leaf>\n"
381 " <leaf name=\"leaf9b\">\n"
382 " <type name=\"boolean\"/>\n"
383 " <default value=\"false\"/>\n"
384 " </leaf>\n"
385 " </choice>\n"
386 " <leaf name=\"leaf10\">\n"
387 " <type name=\"boolean\"/>\n"
Michal Vasko22e0f3a2021-09-22 12:19:23 +0200388 " </leaf>\n");
389 strcpy(ori_res + strlen(ori_res),
FredGand944bdc2019-11-05 21:57:07 +0800390 " <leaf name=\"leaf11\">\n"
391 " <type name=\"enumeration\">\n"
392 " <enum name=\"one\"/>\n"
393 " <enum name=\"two\"/>\n"
394 " <enum name=\"five\">\n"
395 " <value value=\"5\"/>\n"
396 " </enum>\n"
397 " </type>\n"
398 " </leaf>\n"
399 " <leaf name=\"leaf12\">\n"
400 " <type name=\"bits\">\n"
401 " <bit name=\"flag0\">\n"
402 " <position value=\"0\"/>\n"
403 " </bit>\n"
404 " <bit name=\"flag1\"/>\n"
405 " <bit name=\"flag2\">\n"
406 " <position value=\"2\"/>\n"
407 " </bit>\n"
408 " <bit name=\"flag3\">\n"
409 " <position value=\"3\"/>\n"
410 " </bit>\n"
411 " </type>\n"
412 " <default value=\"flag0 flag3\"/>\n"
413 " </leaf>\n"
414 " <leaf name=\"leaf13\">\n"
415 " <type name=\"binary\"/>\n"
416 " </leaf>\n"
417 " <leaf name=\"leaf14\">\n"
418 " <type name=\"leafref\">\n"
419 " <path value=\"/cont1/leaf17\"/>\n"
420 " </type>\n"
421 " </leaf>\n"
422 " <leaf name=\"leaf15\">\n"
423 " <type name=\"empty\"/>\n"
424 " </leaf>\n"
425 " <leaf name=\"leaf16\">\n"
426 " <type name=\"union\">\n"
427 " <type name=\"instance-identifier\">\n"
428 " <require-instance value=\"true\"/>\n"
429 " </type>\n"
430 " <type name=\"int8\"/>\n"
431 " </type>\n"
432 " </leaf>\n"
433 " <list name=\"list1\">\n"
434 " <key value=\"leaf18\"/>\n"
435 " <unique tag=\"leaf19\"/>\n"
436 " <min-elements value=\"1\"/>\n"
437 " <max-elements value=\"20\"/>\n"
438 " <leaf name=\"leaf18\">\n"
439 " <type name=\"string\"/>\n"
440 " </leaf>\n"
441 " <leaf name=\"leaf19\">\n"
442 " <type name=\"uint32\"/>\n"
443 " </leaf>\n"
444 " <anyxml name=\"axml1\"/>\n"
445 " <anydata name=\"adata1\"/>\n"
446 " <action name=\"act1\">\n"
447 " <input>\n"
448 " <leaf name=\"leaf24\">\n"
449 " <type name=\"string\"/>\n"
450 " </leaf>\n"
451 " </input>\n"
452 " <output>\n"
453 " <leaf name=\"leaf25\">\n"
454 " <type name=\"string\"/>\n"
455 " </leaf>\n"
456 " </output>\n"
457 " </action>\n"
458 " <notification name=\"notif1\">\n"
459 " <leaf name=\"leaf26\">\n"
460 " <type name=\"string\"/>\n"
461 " </leaf>\n"
462 " </notification>\n"
463 " </list>\n"
464 " <leaf-list name=\"llist1\">\n"
465 " <type name=\"tdef1\"/>\n"
466 " <ordered-by value=\"user\"/>\n"
467 " </leaf-list>\n"
468 " <list name=\"list2\">\n"
469 " <key value=\"leaf27 leaf28\"/>\n"
470 " <leaf name=\"leaf27\">\n"
471 " <type name=\"uint8\"/>\n"
472 " </leaf>\n"
473 " <leaf name=\"leaf28\">\n"
474 " <type name=\"uint8\"/>\n"
475 " </leaf>\n"
476 " </list>\n"
477 " <leaf name=\"leaf29\">\n"
478 " <type name=\"instance-identifier\"/>\n"
479 " </leaf>\n"
480 " <container name=\"must-deviations-container\">\n"
481 " <presence value=\"Allows deviations on the leaf\"/>\n"
482 " <leaf name=\"leaf30\">\n"
483 " <type name=\"string\"/>\n"
484 " </leaf>\n"
485 " </container>\n"
486 " <leaf name=\"leaf23\">\n"
487 " <type name=\"empty\"/>\n"
488 " </leaf>\n"
489 " </container>\n"
490 " <container name=\"test-when\">\n"
491 " <leaf name=\"when-check\">\n"
492 " <type name=\"boolean\"/>\n"
493 " </leaf>\n"
494 " <leaf name=\"gated-data\">\n"
495 " <when condition=\"../when-check = 'true'\"/>\n"
496 " <type name=\"uint16\"/>\n"
497 " </leaf>\n"
498 " </container>\n"
499 " <augment target-node=\"/cont1\">\n"
500 " <leaf name=\"leaf17\">\n"
501 " <type name=\"string\"/>\n"
502 " </leaf>\n"
503 " </augment>\n"
504 " <rpc name=\"rpc1\">\n"
505 " <input>\n"
506 " <leaf name=\"leaf20\">\n"
507 " <type name=\"tdef1\"/>\n"
508 " </leaf>\n"
509 " </input>\n"
510 " <output>\n"
511 " <container name=\"cont2\">\n"
512 " <leaf name=\"leaf21\">\n"
513 " <type name=\"empty\"/>\n"
514 " </leaf>\n"
515 " </container>\n"
516 " </output>\n"
517 " </rpc>\n"
Michal Vasko22e0f3a2021-09-22 12:19:23 +0200518 "</module>\n");
FredGand944bdc2019-11-05 21:57:07 +0800519
Radek Krejcia5bba312020-01-09 15:41:20 +0100520 char *printed;
Radek Krejci241f6b52020-05-21 18:13:49 +0200521 struct ly_out *out;
Radek Krejcia5bba312020-01-09 15:41:20 +0100522
Radek Krejci84ce7b12020-06-11 17:28:25 +0200523 assert_int_equal(LY_SUCCESS, ly_out_new_memory(&printed, 0, &out));
FredGand944bdc2019-11-05 21:57:07 +0800524
Radek Iša56ca9e42020-09-08 18:42:00 +0200525 UTEST_ADD_MODULE(orig, LYS_IN_YANG, NULL, &mod);
Michal Vasko7c8439f2020-08-05 13:25:19 +0200526 assert_int_equal(LY_SUCCESS, lys_print_module(out, mod, LYS_OUT_YIN, 0, 0));
Michal Vasko63f3d842020-07-08 10:10:14 +0200527 assert_int_equal(strlen(ori_res), ly_out_printed(out));
FredGand944bdc2019-11-05 21:57:07 +0800528 assert_string_equal(printed, ori_res);
Radek Krejcia5bba312020-01-09 15:41:20 +0100529
Michal Vasko7c8439f2020-08-05 13:25:19 +0200530 ly_out_free(out, NULL, 1);
Michal Vasko22e0f3a2021-09-22 12:19:23 +0200531 free(orig);
532 free(ori_res);
Michal Vasko7c8439f2020-08-05 13:25:19 +0200533}
FredGand944bdc2019-11-05 21:57:07 +0800534
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100535static LY_ERR
536test_imp_clb(const char *UNUSED(mod_name), const char *UNUSED(mod_rev), const char *UNUSED(submod_name),
537 const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format,
538 const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
Michal Vasko7c8439f2020-08-05 13:25:19 +0200539{
540 *module_data = user_data;
541 *format = LYS_IN_YIN;
542 *free_module_data = NULL;
543 return LY_SUCCESS;
544}
545
546static void
547test_submodule(void **state)
548{
Michal Vasko4de7d072021-07-09 09:13:18 +0200549 struct lys_module *mod;
Michal Vasko7c8439f2020-08-05 13:25:19 +0200550
551 const char *mod_yin =
552 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
553 "<module name=\"a\"\n"
554 " xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"\n"
555 " xmlns:a_mod=\"urn:a\">\n"
556 " <yang-version value=\"1.1\"/>\n"
557 " <namespace uri=\"urn:a\"/>\n"
558 " <prefix value=\"a_mod\"/>\n"
559 " <include module=\"a-sub\"/>\n"
560 "</module>\n";
561
562 char *submod_yin =
563 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
564 "<submodule name=\"a-sub\"\n"
565 " xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"\n"
566 " xmlns:a_mod=\"urn:a\"\n"
567 " xmlns:yt=\"urn:ietf:params:xml:ns:yang:ietf-yang-types\">\n"
568 " <yang-version value=\"1.1\"/>\n"
569 " <belongs-to module=\"a\">\n"
570 " <prefix value=\"a_mod\"/>\n"
571 " </belongs-to>\n"
572 " <import module=\"ietf-yang-types\">\n"
573 " <prefix value=\"yt\"/>\n"
574 " <revision-date date=\"2013-07-15\"/>\n"
575 " </import>\n\n"
576 " <description>\n"
577 " <text>YANG types</text>\n"
578 " </description>\n"
579 " <reference>\n"
580 " <text>RFC reference</text>\n"
581 " </reference>\n"
582 "</submodule>\n";
583
584 char *printed;
585 struct ly_out *out;
586
587 assert_int_equal(LY_SUCCESS, ly_out_new_memory(&printed, 0, &out));
Michal Vasko7c8439f2020-08-05 13:25:19 +0200588
Radek Iša56ca9e42020-09-08 18:42:00 +0200589 ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, submod_yin);
590
591 UTEST_ADD_MODULE(mod_yin, LYS_IN_YIN, NULL, &mod);
Michal Vasko7997d5a2021-02-22 10:55:56 +0100592 assert_int_equal(LY_SUCCESS, lys_print_submodule(out, mod->parsed->includes[0].submodule, LYS_OUT_YIN, 0, 0));
Michal Vasko7c8439f2020-08-05 13:25:19 +0200593 assert_int_equal(strlen(submod_yin), ly_out_printed(out));
594 assert_string_equal(printed, submod_yin);
Radek Krejcia5bba312020-01-09 15:41:20 +0100595
Michal Vasko7c8439f2020-08-05 13:25:19 +0200596 ly_out_free(out, NULL, 1);
FredGand944bdc2019-11-05 21:57:07 +0800597}
598
Radek Krejcib4ac5a92020-11-23 17:54:33 +0100599int
600main(void)
FredGand944bdc2019-11-05 21:57:07 +0800601{
602 const struct CMUnitTest tests[] = {
Radek Iša56ca9e42020-09-08 18:42:00 +0200603 UTEST(test_module),
604 UTEST(test_submodule),
FredGand944bdc2019-11-05 21:57:07 +0800605 };
606
607 return cmocka_run_group_tests(tests, NULL, NULL);
608}