blob: 3c499770d084ca573d5dc51853459ff7a3f7dca9 [file] [log] [blame]
Radek Krejci3a4889a2020-05-19 17:01:58 +02001/*
2 * @file test_schema.c
3 * @author: Radek Krejci <rkrejci@cesnet.cz>
4 * @brief unit tests for schema related functions
5 *
6 * Copyright (c) 2018-2019 CESNET, z.s.p.o.
7 *
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_
Radek Krejci18abde42020-06-13 20:04:39 +020015#include "test_schema.h"
16
Radek Krejcica376bd2020-06-11 16:04:06 +020017#include <string.h>
18
Radek Krejci18abde42020-06-13 20:04:39 +020019#include "log.h"
20#include "parser_schema.h"
21#include "tree_schema.h"
Radek Krejci3a4889a2020-05-19 17:01:58 +020022
Radek Krejci18abde42020-06-13 20:04:39 +020023LY_ERR
24test_imp_clb(const char *UNUSED(mod_name), const char *UNUSED(mod_rev), const char *UNUSED(submod_name),
Radek Krejcib4ac5a92020-11-23 17:54:33 +010025 const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format,
26 const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
Radek Krejci18abde42020-06-13 20:04:39 +020027{
28 *module_data = user_data;
Radek Krejci85ac8312021-03-03 20:21:33 +010029 if ((*module_data)[0] == '<') {
30 *format = LYS_IN_YIN;
31 } else {
32 *format = LYS_IN_YANG;
33 }
Radek Krejci18abde42020-06-13 20:04:39 +020034 *free_module_data = NULL;
35 return LY_SUCCESS;
36}
Radek Krejci3a4889a2020-05-19 17:01:58 +020037
38/**
Radek Krejci18abde42020-06-13 20:04:39 +020039 * DECLARE OTHER SCHEMA TESTS
Radek Krejci3a4889a2020-05-19 17:01:58 +020040 */
Radek Krejci18abde42020-06-13 20:04:39 +020041/* test_schema_common.c */
42void test_getnext(void **state);
43void test_date(void **state);
44void test_revisions(void **state);
45void test_typedef(void **state);
Michal Vasko6b26e742020-07-17 15:02:10 +020046void test_accessible_tree(void **state);
Radek Krejci589c5472021-01-20 10:29:06 +010047void test_includes(void **state);
Radek Krejci18abde42020-06-13 20:04:39 +020048
49/* test_schema_stmts.c */
50void test_identity(void **state);
51void test_feature(void **state);
Radek Krejci3a4889a2020-05-19 17:01:58 +020052
Radek Krejci85ac8312021-03-03 20:21:33 +010053/* test_schema_extensions.c */
54void test_extension_argument(void **state);
55void test_extension_argument_element(void **state);
56
Radek Krejcib4ac5a92020-11-23 17:54:33 +010057int
58main(void)
Radek Krejci3a4889a2020-05-19 17:01:58 +020059{
60 const struct CMUnitTest tests[] = {
61 /** test_schema_common.c */
Radek Iša56ca9e42020-09-08 18:42:00 +020062 UTEST(test_getnext),
63 UTEST(test_date),
64 UTEST(test_revisions),
65 UTEST(test_typedef),
66 UTEST(test_accessible_tree),
Radek Krejci589c5472021-01-20 10:29:06 +010067 UTEST(test_includes),
Radek Krejci3a4889a2020-05-19 17:01:58 +020068
69 /** test_schema_stmts.c */
Radek Iša56ca9e42020-09-08 18:42:00 +020070 UTEST(test_identity),
71 UTEST(test_feature),
Radek Krejci85ac8312021-03-03 20:21:33 +010072
73 /** test_schema_extensions.c */
74 UTEST(test_extension_argument),
75 UTEST(test_extension_argument_element),
Radek Krejci3a4889a2020-05-19 17:01:58 +020076 };
77
78 return cmocka_run_group_tests(tests, NULL, NULL);
79}