]> git.proxmox.com Git - mirror_frr.git/blob - pceplib/test/pcep_msg_object_error_types_test.c
*: auto-convert to SPDX License IDs
[mirror_frr.git] / pceplib / test / pcep_msg_object_error_types_test.c
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 /*
3 * This file is part of the PCEPlib, a PCEP protocol library.
4 *
5 * Copyright (C) 2020 Volta Networks https://voltanet.io/
6 *
7 * Author : Brady Johnson <brady@voltanet.io>
8 *
9 */
10
11
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15
16 #include <stdio.h>
17
18 #include <CUnit/CUnit.h>
19
20 #include "pcep_msg_object_error_types.h"
21 #include "pcep_msg_object_error_types_test.h"
22 #include "pcep_utils_logging.h"
23 #include "pcep_utils_memory.h"
24
25 int pcep_object_error_types_test_suite_setup(void)
26 {
27 pceplib_memory_reset();
28 set_logging_level(LOG_DEBUG);
29 return 0;
30 }
31
32 int pcep_object_error_types_test_suite_teardown(void)
33 {
34 printf("\n");
35 pceplib_memory_dump();
36 return 0;
37 }
38
39 void pcep_object_error_types_test_setup(void)
40 {
41 }
42
43 void pcep_object_error_types_test_teardown(void)
44 {
45 }
46
47 void test_get_error_type_str()
48 {
49 const char *error_type_str;
50 int i = 0;
51 for (; i < MAX_ERROR_TYPE; i++) {
52 error_type_str = get_error_type_str(i);
53 CU_ASSERT_PTR_NOT_NULL(error_type_str);
54 }
55
56 CU_ASSERT_PTR_NULL(get_error_type_str(-1));
57 CU_ASSERT_PTR_NULL(get_error_type_str(MAX_ERROR_TYPE));
58 }
59
60 void test_get_error_value_str()
61 {
62 const char *error_value_str;
63 int i = 0, j = 0;
64
65 for (; i < MAX_ERROR_TYPE; i++) {
66 for (; j < MAX_ERROR_VALUE; j++) {
67 error_value_str = get_error_value_str(i, j);
68 CU_ASSERT_PTR_NOT_NULL(error_value_str);
69 }
70 }
71
72 CU_ASSERT_PTR_NULL(get_error_value_str(-1, 0));
73 CU_ASSERT_PTR_NULL(get_error_value_str(MAX_ERROR_TYPE, 0));
74 CU_ASSERT_PTR_NULL(get_error_value_str(1, -1));
75 CU_ASSERT_PTR_NULL(get_error_value_str(1, MAX_ERROR_VALUE));
76 }