]> git.proxmox.com Git - mirror_frr.git/blob - pceplib/test/pcep_msg_object_error_types_test.c
Merge pull request #8008 from chiragshah6/yang_nb5
[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 #include <stdio.h>
25
26 #include <CUnit/CUnit.h>
27
28 #include "pcep_msg_object_error_types.h"
29 #include "pcep_msg_object_error_types_test.h"
30 #include "pcep_utils_logging.h"
31 #include "pcep_utils_memory.h"
32
33 int pcep_object_error_types_test_suite_setup(void)
34 {
35 pceplib_memory_reset();
36 set_logging_level(LOG_DEBUG);
37 return 0;
38 }
39
40 int pcep_object_error_types_test_suite_teardown(void)
41 {
42 printf("\n");
43 pceplib_memory_dump();
44 return 0;
45 }
46
47 void pcep_object_error_types_test_setup(void)
48 {
49 }
50
51 void pcep_object_error_types_test_teardown(void)
52 {
53 }
54
55 void test_get_error_type_str()
56 {
57 const char *error_type_str;
58 int i = 0;
59 for (; i < MAX_ERROR_TYPE; i++) {
60 error_type_str = get_error_type_str(i);
61 CU_ASSERT_PTR_NOT_NULL(error_type_str);
62 }
63
64 CU_ASSERT_PTR_NULL(get_error_type_str(-1));
65 CU_ASSERT_PTR_NULL(get_error_type_str(MAX_ERROR_TYPE));
66 }
67
68 void test_get_error_value_str()
69 {
70 const char *error_value_str;
71 int i = 0, j = 0;
72
73 for (; i < MAX_ERROR_TYPE; i++) {
74 for (; j < MAX_ERROR_VALUE; j++) {
75 error_value_str = get_error_value_str(i, j);
76 CU_ASSERT_PTR_NOT_NULL(error_value_str);
77 }
78 }
79
80 CU_ASSERT_PTR_NULL(get_error_value_str(-1, 0));
81 CU_ASSERT_PTR_NULL(get_error_value_str(MAX_ERROR_TYPE, 0));
82 CU_ASSERT_PTR_NULL(get_error_value_str(1, -1));
83 CU_ASSERT_PTR_NULL(get_error_value_str(1, MAX_ERROR_VALUE));
84 }