]> git.proxmox.com Git - mirror_frr.git/blob - pceplib/test/pcep_msg_object_error_types_test.c
Merge pull request #8304 from mjstapp/fix_zmq_xref
[mirror_frr.git] / pceplib / test / pcep_msg_object_error_types_test.c
1 /*
2 * This file is part of the PCEPlib, a PCEP protocol library.
3 *
4 * Copyright (C) 2020 Volta Networks https://voltanet.io/
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Author : Brady Johnson <brady@voltanet.io>
20 *
21 */
22
23
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27
28 #include <stdio.h>
29
30 #include <CUnit/CUnit.h>
31
32 #include "pcep_msg_object_error_types.h"
33 #include "pcep_msg_object_error_types_test.h"
34 #include "pcep_utils_logging.h"
35 #include "pcep_utils_memory.h"
36
37 int pcep_object_error_types_test_suite_setup(void)
38 {
39 pceplib_memory_reset();
40 set_logging_level(LOG_DEBUG);
41 return 0;
42 }
43
44 int pcep_object_error_types_test_suite_teardown(void)
45 {
46 printf("\n");
47 pceplib_memory_dump();
48 return 0;
49 }
50
51 void pcep_object_error_types_test_setup(void)
52 {
53 }
54
55 void pcep_object_error_types_test_teardown(void)
56 {
57 }
58
59 void test_get_error_type_str()
60 {
61 const char *error_type_str;
62 int i = 0;
63 for (; i < MAX_ERROR_TYPE; i++) {
64 error_type_str = get_error_type_str(i);
65 CU_ASSERT_PTR_NOT_NULL(error_type_str);
66 }
67
68 CU_ASSERT_PTR_NULL(get_error_type_str(-1));
69 CU_ASSERT_PTR_NULL(get_error_type_str(MAX_ERROR_TYPE));
70 }
71
72 void test_get_error_value_str()
73 {
74 const char *error_value_str;
75 int i = 0, j = 0;
76
77 for (; i < MAX_ERROR_TYPE; i++) {
78 for (; j < MAX_ERROR_VALUE; j++) {
79 error_value_str = get_error_value_str(i, j);
80 CU_ASSERT_PTR_NOT_NULL(error_value_str);
81 }
82 }
83
84 CU_ASSERT_PTR_NULL(get_error_value_str(-1, 0));
85 CU_ASSERT_PTR_NULL(get_error_value_str(MAX_ERROR_TYPE, 0));
86 CU_ASSERT_PTR_NULL(get_error_value_str(1, -1));
87 CU_ASSERT_PTR_NULL(get_error_value_str(1, MAX_ERROR_VALUE));
88 }