Radek Krejci | 3a4889a | 2020-05-19 17:01:58 +0200 | [diff] [blame] | 1 | /* |
| 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ša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 14 | #define _UTEST_MAIN_ |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 15 | #include "test_schema.h" |
| 16 | |
Radek Krejci | ca376bd | 2020-06-11 16:04:06 +0200 | [diff] [blame] | 17 | #include <string.h> |
| 18 | |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 19 | #include "log.h" |
| 20 | #include "parser_schema.h" |
Radek Krejci | 8297b79 | 2020-08-16 14:49:05 +0200 | [diff] [blame] | 21 | #include "set.h" |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 22 | #include "tree_schema.h" |
Radek Krejci | 3a4889a | 2020-05-19 17:01:58 +0200 | [diff] [blame] | 23 | |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 24 | LY_ERR |
| 25 | test_imp_clb(const char *UNUSED(mod_name), const char *UNUSED(mod_rev), const char *UNUSED(submod_name), |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 26 | const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format, |
| 27 | const char **module_data, void (**free_module_data)(void *model_data, void *user_data)) |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 28 | { |
| 29 | *module_data = user_data; |
Radek Krejci | 85ac831 | 2021-03-03 20:21:33 +0100 | [diff] [blame] | 30 | if ((*module_data)[0] == '<') { |
| 31 | *format = LYS_IN_YIN; |
| 32 | } else { |
| 33 | *format = LYS_IN_YANG; |
| 34 | } |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 35 | *free_module_data = NULL; |
| 36 | return LY_SUCCESS; |
| 37 | } |
Radek Krejci | 3a4889a | 2020-05-19 17:01:58 +0200 | [diff] [blame] | 38 | |
| 39 | /** |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 40 | * DECLARE OTHER SCHEMA TESTS |
Radek Krejci | 3a4889a | 2020-05-19 17:01:58 +0200 | [diff] [blame] | 41 | */ |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 42 | /* test_schema_common.c */ |
| 43 | void test_getnext(void **state); |
| 44 | void test_date(void **state); |
| 45 | void test_revisions(void **state); |
aPiecek | 4f49a14 | 2021-06-29 15:32:39 +0200 | [diff] [blame] | 46 | void test_collision_typedef(void **state); |
aPiecek | 0b36561 | 2021-06-30 13:12:58 +0200 | [diff] [blame] | 47 | void test_collision_grouping(void **state); |
aPiecek | 14d07f0 | 2021-06-30 09:46:50 +0200 | [diff] [blame] | 48 | void test_collision_identity(void **state); |
| 49 | void test_collision_feature(void **state); |
Michal Vasko | 6b26e74 | 2020-07-17 15:02:10 +0200 | [diff] [blame] | 50 | void test_accessible_tree(void **state); |
Radek Krejci | 589c547 | 2021-01-20 10:29:06 +0100 | [diff] [blame] | 51 | void test_includes(void **state); |
Radek Krejci | 18abde4 | 2020-06-13 20:04:39 +0200 | [diff] [blame] | 52 | |
| 53 | /* test_schema_stmts.c */ |
| 54 | void test_identity(void **state); |
| 55 | void test_feature(void **state); |
Radek Krejci | 3a4889a | 2020-05-19 17:01:58 +0200 | [diff] [blame] | 56 | |
Radek Krejci | 85ac831 | 2021-03-03 20:21:33 +0100 | [diff] [blame] | 57 | /* test_schema_extensions.c */ |
| 58 | void test_extension_argument(void **state); |
| 59 | void test_extension_argument_element(void **state); |
| 60 | |
Radek Krejci | b4ac5a9 | 2020-11-23 17:54:33 +0100 | [diff] [blame] | 61 | int |
| 62 | main(void) |
Radek Krejci | 3a4889a | 2020-05-19 17:01:58 +0200 | [diff] [blame] | 63 | { |
| 64 | const struct CMUnitTest tests[] = { |
| 65 | /** test_schema_common.c */ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 66 | UTEST(test_getnext), |
| 67 | UTEST(test_date), |
| 68 | UTEST(test_revisions), |
aPiecek | 4f49a14 | 2021-06-29 15:32:39 +0200 | [diff] [blame] | 69 | UTEST(test_collision_typedef), |
aPiecek | 0b36561 | 2021-06-30 13:12:58 +0200 | [diff] [blame] | 70 | UTEST(test_collision_grouping), |
aPiecek | 14d07f0 | 2021-06-30 09:46:50 +0200 | [diff] [blame] | 71 | UTEST(test_collision_identity), |
| 72 | UTEST(test_collision_feature), |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 73 | UTEST(test_accessible_tree), |
Radek Krejci | 589c547 | 2021-01-20 10:29:06 +0100 | [diff] [blame] | 74 | UTEST(test_includes), |
Radek Krejci | 3a4889a | 2020-05-19 17:01:58 +0200 | [diff] [blame] | 75 | |
| 76 | /** test_schema_stmts.c */ |
Radek Iša | 56ca9e4 | 2020-09-08 18:42:00 +0200 | [diff] [blame] | 77 | UTEST(test_identity), |
| 78 | UTEST(test_feature), |
Radek Krejci | 85ac831 | 2021-03-03 20:21:33 +0100 | [diff] [blame] | 79 | |
| 80 | /** test_schema_extensions.c */ |
| 81 | UTEST(test_extension_argument), |
| 82 | UTEST(test_extension_argument_element), |
Radek Krejci | 3a4889a | 2020-05-19 17:01:58 +0200 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | return cmocka_run_group_tests(tests, NULL, NULL); |
| 86 | } |