Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 1 | /* |
| 2 | * @file set.c |
| 3 | * @author: Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * @brief unit tests for functions from set.c |
| 5 | * |
| 6 | * Copyright (c) 2018 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 Krejci | 535ea9f | 2020-05-29 16:01:05 +0200 | [diff] [blame] | 14 | |
| 15 | #define _GNU_SOURCE |
Radek Krejci | f8dc59a | 2020-11-25 13:47:44 +0100 | [diff] [blame] | 16 | #define _POSIX_C_SOURCE 200809L /* strdup */ |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 17 | |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 18 | #include <stdarg.h> |
| 19 | #include <stddef.h> |
Radek Krejci | 535ea9f | 2020-05-29 16:01:05 +0200 | [diff] [blame] | 20 | #include <stdlib.h> |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 21 | #include <setjmp.h> |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 22 | #include <string.h> |
| 23 | |
Radek Krejci | 535ea9f | 2020-05-29 16:01:05 +0200 | [diff] [blame] | 24 | #include <cmocka.h> |
| 25 | |
Radek Krejci | 70593c1 | 2020-06-13 20:48:09 +0200 | [diff] [blame] | 26 | #include "set.h" |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 27 | |
| 28 | #define BUFSIZE 1024 |
| 29 | char logbuf[BUFSIZE] = {0}; |
| 30 | |
| 31 | static void |
| 32 | logger(LY_LOG_LEVEL level, const char *msg, const char *path) |
| 33 | { |
| 34 | (void) level; /* unused */ |
| 35 | (void) path; /* unused */ |
| 36 | |
| 37 | strncpy(logbuf, msg, BUFSIZE - 1); |
| 38 | } |
| 39 | |
| 40 | static int |
| 41 | logger_setup(void **state) |
| 42 | { |
| 43 | (void) state; /* unused */ |
| 44 | |
| 45 | ly_set_log_clb(logger, 0); |
| 46 | |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | static void |
| 51 | test_basics(void **state) |
| 52 | { |
| 53 | (void) state; /* unused */ |
| 54 | |
| 55 | struct ly_set *set; |
| 56 | char *str; |
| 57 | unsigned int u; |
| 58 | void *ptr; |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 59 | uint32_t index; |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 60 | |
| 61 | /* creation - everything is empty */ |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 62 | assert_int_equal(LY_SUCCESS, ly_set_new(&set)); |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 63 | assert_non_null(set); |
| 64 | assert_int_equal(0, set->count); |
| 65 | assert_int_equal(0, set->size); |
| 66 | assert_null(set->objs); |
| 67 | |
| 68 | /* add a testing object */ |
| 69 | str = strdup("test string"); |
| 70 | assert_non_null(str); |
| 71 | |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 72 | assert_int_equal(LY_SUCCESS, ly_set_add(set, str, 0, NULL)); |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 73 | assert_int_not_equal(0, set->size); |
| 74 | assert_int_equal(1, set->count); |
| 75 | assert_non_null(set->objs); |
| 76 | assert_non_null(set->objs[0]); |
| 77 | |
| 78 | /* check the presence of the testing data */ |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 79 | assert_int_not_equal(0, ly_set_contains(set, str, &index)); |
| 80 | assert_int_equal(0, index); |
| 81 | assert_int_equal(0, ly_set_contains(set, str - 1, NULL)); |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 82 | |
| 83 | /* remove data, but keep the set */ |
| 84 | u = set->size; |
| 85 | ptr = set->objs; |
| 86 | ly_set_clean(set, free); |
| 87 | assert_int_equal(0, set->count); |
| 88 | assert_int_equal(u, set->size); |
| 89 | assert_ptr_equal(ptr, set->objs); |
| 90 | |
| 91 | /* remove buffer, but keep the set object */ |
| 92 | ly_set_erase(set, NULL); |
| 93 | assert_int_equal(0, set->count); |
| 94 | assert_int_equal(0, set->size); |
| 95 | assert_ptr_equal(NULL, set->objs); |
| 96 | |
| 97 | /* final cleanup */ |
| 98 | ly_set_free(set, NULL); |
| 99 | } |
| 100 | |
| 101 | static void |
| 102 | test_inval(void **state) |
| 103 | { |
| 104 | struct ly_set set; |
| 105 | memset(&set, 0, sizeof set); |
| 106 | |
| 107 | ly_set_clean(NULL, NULL); |
Radek Krejci | 0bfec16 | 2019-05-02 09:54:25 +0200 | [diff] [blame] | 108 | assert_string_equal(logbuf, ""); |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 109 | |
| 110 | ly_set_erase(NULL, NULL); |
Radek Krejci | 0bfec16 | 2019-05-02 09:54:25 +0200 | [diff] [blame] | 111 | assert_string_equal(logbuf, ""); |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 112 | |
| 113 | ly_set_free(NULL, NULL); |
Radek Krejci | 0bfec16 | 2019-05-02 09:54:25 +0200 | [diff] [blame] | 114 | assert_string_equal(logbuf, ""); |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 115 | |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 116 | assert_int_equal(LY_EINVAL, ly_set_dup(NULL, NULL, NULL)); |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 117 | assert_string_equal(logbuf, "Invalid argument set (ly_set_dup())."); |
| 118 | |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 119 | assert_int_equal(LY_EINVAL, ly_set_add(NULL, NULL, 0, NULL)); |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 120 | assert_string_equal(logbuf, "Invalid argument set (ly_set_add())."); |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 121 | |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 122 | assert_int_equal(LY_EINVAL, ly_set_merge(NULL, NULL, 0, NULL)); |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 123 | assert_string_equal(logbuf, "Invalid argument trg (ly_set_merge())."); |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 124 | assert_int_equal(LY_SUCCESS, ly_set_merge(&set, NULL, 0, NULL)); |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 125 | |
Radek Krejci | 820d226 | 2018-09-20 12:15:31 +0200 | [diff] [blame] | 126 | assert_int_equal(LY_EINVAL, ly_set_rm_index(NULL, 0, NULL)); |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 127 | assert_string_equal(logbuf, "Invalid argument set (ly_set_rm_index())."); |
Radek Krejci | 820d226 | 2018-09-20 12:15:31 +0200 | [diff] [blame] | 128 | assert_int_equal(LY_EINVAL, ly_set_rm_index(&set, 1, NULL)); |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 129 | assert_string_equal(logbuf, "Invalid argument index (ly_set_rm_index())."); |
| 130 | |
Radek Krejci | 820d226 | 2018-09-20 12:15:31 +0200 | [diff] [blame] | 131 | assert_int_equal(LY_EINVAL, ly_set_rm(NULL, NULL, NULL)); |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 132 | assert_string_equal(logbuf, "Invalid argument set (ly_set_rm())."); |
Radek Krejci | 820d226 | 2018-09-20 12:15:31 +0200 | [diff] [blame] | 133 | assert_int_equal(LY_EINVAL, ly_set_rm(&set, NULL, NULL)); |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 134 | assert_string_equal(logbuf, "Invalid argument object (ly_set_rm())."); |
Radek Krejci | 820d226 | 2018-09-20 12:15:31 +0200 | [diff] [blame] | 135 | assert_int_equal(LY_EINVAL, ly_set_rm(&set, &state, NULL)); |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 136 | assert_string_equal(logbuf, "Invalid argument object (ly_set_rm())."); |
| 137 | } |
| 138 | |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 139 | static void |
| 140 | test_duplication(void **state) |
| 141 | { |
| 142 | (void) state; /* unused */ |
| 143 | |
| 144 | struct ly_set *orig, *new; |
| 145 | char *str; |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 146 | uint32_t index; |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 147 | |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 148 | assert_int_equal(LY_SUCCESS, ly_set_new(&orig)); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 149 | assert_non_null(orig); |
| 150 | |
| 151 | /* add a testing object */ |
| 152 | str = strdup("test string"); |
| 153 | assert_non_null(str); |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 154 | assert_int_equal(LY_SUCCESS, ly_set_add(orig, str, 0, &index)); |
| 155 | assert_int_equal(0, index); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 156 | |
| 157 | /* duplicate the set - without duplicator, so the new set will point to the same string */ |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 158 | assert_int_equal(LY_SUCCESS, ly_set_dup(orig, NULL, &new)); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 159 | assert_non_null(new); |
| 160 | assert_ptr_not_equal(orig, new); |
| 161 | assert_int_equal(orig->count, new->count); |
| 162 | assert_ptr_equal(orig->objs[0], new->objs[0]); |
| 163 | |
| 164 | ly_set_free(new, NULL); |
| 165 | |
| 166 | /* duplicate the set - with duplicator, so the new set will point to a different buffer with the same content */ |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 167 | assert_int_equal(LY_SUCCESS, ly_set_dup(orig, (void*(*)(void*))strdup, &new)); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 168 | assert_non_null(new); |
| 169 | assert_ptr_not_equal(orig, new); |
| 170 | assert_int_equal(orig->count, new->count); |
| 171 | assert_ptr_not_equal(orig->objs[0], new->objs[0]); |
| 172 | assert_string_equal(orig->objs[0], new->objs[0]); |
| 173 | |
| 174 | /* cleanup */ |
| 175 | ly_set_free(new, free); |
| 176 | ly_set_free(orig, free); |
| 177 | } |
| 178 | |
| 179 | static void |
| 180 | test_add(void **state) |
| 181 | { |
| 182 | (void) state; /* unused */ |
| 183 | |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 184 | uint32_t u, index; |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 185 | char *str = "test string"; |
| 186 | struct ly_set set; |
| 187 | memset(&set, 0, sizeof set); |
| 188 | |
| 189 | /* add a testing object */ |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 190 | assert_int_equal(LY_SUCCESS, ly_set_add(&set, str, 0, &index)); |
| 191 | assert_int_equal(0, index); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 192 | |
| 193 | /* test avoiding data duplicities */ |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 194 | assert_int_equal(LY_SUCCESS, ly_set_add(&set, str, 0, &index)); |
| 195 | assert_int_equal(0, index); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 196 | assert_int_equal(1, set.count); |
Radek Krejci | 3d92e44 | 2020-10-12 12:48:13 +0200 | [diff] [blame] | 197 | assert_int_equal(LY_SUCCESS, ly_set_add(&set, str, 1, &index)); |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 198 | assert_int_equal(1, index); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 199 | assert_int_equal(2, set.count); |
| 200 | |
| 201 | /* test array resizing */ |
| 202 | u = set.size; |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 203 | for (uint32_t expected_index = 2; expected_index <= u; ++expected_index) { |
Radek Krejci | 3d92e44 | 2020-10-12 12:48:13 +0200 | [diff] [blame] | 204 | assert_int_equal(LY_SUCCESS, ly_set_add(&set, str, 1, &index)); |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 205 | assert_int_equal(expected_index, index); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 206 | } |
| 207 | assert_true(u != set.size); |
| 208 | |
| 209 | /* cleanup */ |
| 210 | ly_set_erase(&set, NULL); |
| 211 | } |
| 212 | |
| 213 | static void |
| 214 | test_merge(void **state) |
| 215 | { |
| 216 | (void) state; /* unused */ |
| 217 | |
| 218 | char *str1, *str2; |
| 219 | struct ly_set one, two; |
| 220 | memset(&one, 0, sizeof one); |
| 221 | memset(&two, 0, sizeof two); |
| 222 | |
| 223 | str1 = strdup("string1"); |
| 224 | str2 = strdup("string2"); |
| 225 | |
| 226 | /* fill first set |
| 227 | * - str1 is the same as in two, so it must not be freed! */ |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 228 | assert_int_equal(LY_SUCCESS, ly_set_add(&one, str1, 0, NULL)); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 229 | |
| 230 | /* fill second set */ |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 231 | assert_int_equal(LY_SUCCESS, ly_set_add(&two, str1, 0, NULL)); |
| 232 | assert_int_equal(LY_SUCCESS, ly_set_add(&two, str2, 0, NULL)); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 233 | |
| 234 | /* merge with checking duplicities - only one item is added into one; |
| 235 | * also without duplicating data, so it must not be freed at the end */ |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 236 | assert_int_equal(LY_SUCCESS, ly_set_merge(&one, &two, 0, NULL)); |
| 237 | assert_int_equal(2, one.count); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 238 | assert_ptr_equal(one.objs[1], two.objs[1]); |
| 239 | |
| 240 | /* clean and re-fill one (now duplicating str1, to allow testing duplicator) */ |
| 241 | ly_set_clean(&one, NULL); |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 242 | assert_int_equal(LY_SUCCESS, ly_set_add(&one, strdup(str1), 0, NULL)); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 243 | |
| 244 | /* merge without checking duplicities - two items are added into one; |
| 245 | * here also with duplicator */ |
Radek Krejci | 3d92e44 | 2020-10-12 12:48:13 +0200 | [diff] [blame] | 246 | assert_int_equal(LY_SUCCESS, ly_set_merge(&one, &two, 1, (void*(*)(void*))strdup)); |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 247 | assert_int_equal(3, one.count); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 248 | assert_ptr_not_equal(one.objs[1], two.objs[0]); |
| 249 | assert_string_equal(one.objs[1], two.objs[0]); |
| 250 | |
| 251 | /* cleanup */ |
| 252 | ly_set_erase(&one, free); |
| 253 | ly_set_erase(&two, free); |
| 254 | } |
| 255 | |
| 256 | static void |
| 257 | test_rm(void **state) |
| 258 | { |
| 259 | (void) state; /* unused */ |
| 260 | |
| 261 | char *str1, *str2, *str3; |
| 262 | struct ly_set set; |
| 263 | memset(&set, 0, sizeof set); |
| 264 | |
| 265 | /* fill the set */ |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 266 | assert_int_equal(LY_SUCCESS, ly_set_add(&set, "string1", 0, NULL)); |
| 267 | assert_int_equal(LY_SUCCESS, ly_set_add(&set, strdup("string2"), 0, NULL)); |
| 268 | assert_int_equal(LY_SUCCESS, ly_set_add(&set, "string3", 0, NULL)); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 269 | |
| 270 | /* remove by index ... */ |
| 271 | /* ... in the middle ... */ |
Radek Krejci | 820d226 | 2018-09-20 12:15:31 +0200 | [diff] [blame] | 272 | assert_int_equal(LY_SUCCESS, ly_set_rm_index(&set, 1, free)); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 273 | assert_int_equal(2, set.count); |
| 274 | assert_string_not_equal("string2", set.objs[0]); |
| 275 | assert_string_not_equal("string2", set.objs[1]); |
| 276 | /* ... last .. */ |
Radek Krejci | 820d226 | 2018-09-20 12:15:31 +0200 | [diff] [blame] | 277 | assert_int_equal(LY_SUCCESS, ly_set_rm_index(&set, 1, NULL)); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 278 | assert_int_equal(1, set.count); |
| 279 | assert_string_not_equal("string3", set.objs[0]); |
| 280 | /* ... first .. */ |
Radek Krejci | 820d226 | 2018-09-20 12:15:31 +0200 | [diff] [blame] | 281 | assert_int_equal(LY_SUCCESS, ly_set_rm_index(&set, 0, NULL)); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 282 | assert_int_equal(0, set.count); |
| 283 | |
| 284 | /* fill the set */ |
Radek Krejci | ba03a5a | 2020-08-27 14:40:41 +0200 | [diff] [blame] | 285 | assert_int_equal(LY_SUCCESS, ly_set_add(&set, str1 = "string1", 0, NULL)); |
| 286 | assert_int_equal(LY_SUCCESS, ly_set_add(&set, str2 = "string2", 0, NULL)); |
| 287 | assert_int_equal(LY_SUCCESS, ly_set_add(&set, str3 = strdup("string3"), 0, NULL)); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 288 | |
| 289 | /* remove by pointer ... */ |
| 290 | /* ... in the middle ... */ |
Radek Krejci | 820d226 | 2018-09-20 12:15:31 +0200 | [diff] [blame] | 291 | assert_int_equal(LY_SUCCESS, ly_set_rm(&set, str2, NULL)); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 292 | assert_int_equal(2, set.count); |
| 293 | assert_string_not_equal("string2", set.objs[0]); |
| 294 | assert_string_not_equal("string2", set.objs[1]); |
Radek Krejci | 820d226 | 2018-09-20 12:15:31 +0200 | [diff] [blame] | 295 | /* ... last (with destructor) .. */ |
| 296 | assert_int_equal(LY_SUCCESS, ly_set_rm(&set, str3, free)); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 297 | assert_int_equal(1, set.count); |
| 298 | assert_string_not_equal("string3", set.objs[0]); |
| 299 | /* ... first .. */ |
Radek Krejci | 820d226 | 2018-09-20 12:15:31 +0200 | [diff] [blame] | 300 | assert_int_equal(LY_SUCCESS, ly_set_rm(&set, str1, NULL)); |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 301 | assert_int_equal(0, set.count); |
| 302 | |
| 303 | /* cleanup */ |
| 304 | ly_set_erase(&set, NULL); |
| 305 | } |
| 306 | |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 307 | int main(void) |
| 308 | { |
| 309 | const struct CMUnitTest tests[] = { |
| 310 | cmocka_unit_test(test_basics), |
Radek Krejci | 519b043 | 2018-09-18 17:04:57 +0200 | [diff] [blame] | 311 | cmocka_unit_test(test_duplication), |
| 312 | cmocka_unit_test(test_add), |
| 313 | cmocka_unit_test(test_merge), |
| 314 | cmocka_unit_test(test_rm), |
Radek Krejci | e84f12f | 2018-09-18 14:11:50 +0200 | [diff] [blame] | 315 | cmocka_unit_test_setup(test_inval, logger_setup), |
| 316 | }; |
| 317 | |
| 318 | return cmocka_run_group_tests(tests, NULL, NULL); |
| 319 | } |