diff options
| author | Jafar Al-Gharaibeh <jafar@atcorp.com> | 2024-06-13 00:20:09 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-13 00:20:09 -0500 |
| commit | 2e02bd2366ebf877963802d79e66b805ccffbf4c (patch) | |
| tree | 4131dc2e92ef2678f6c1cc1de6e1dddc56d4b1bc /tests/lib | |
| parent | d8e3121cb8470fe9a934100de9170b4ef48b17a6 (diff) | |
| parent | 27e369487eb602b75ea353e8c21333bd83032a86 (diff) | |
Merge pull request #16184 from LabNConsulting/chopps/fe-notify-select
mgmtd: add notification selection to front-end API
Diffstat (limited to 'tests/lib')
| -rw-r--r-- | tests/lib/test_darr.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/lib/test_darr.c b/tests/lib/test_darr.c index 74aedac4b7..87f9e3e564 100644 --- a/tests/lib/test_darr.c +++ b/tests/lib/test_darr.c @@ -20,6 +20,8 @@ * [x] - darr_foreach_i * [x] - darr_foreach_p * [x] - darr_free + * [x] - darr_free_free + * [x] - darr_free_func * [x] - darr_insert * [ ] - darr_insertz * [x] - darr_insert_n @@ -318,6 +320,8 @@ static void test_string(void) uint addlen = strlen(add); char *da1 = NULL; char *da2 = NULL; + const char **strings = NULL; + uint sum = 0; assert(darr_strlen(da1) == 0); @@ -412,6 +416,29 @@ static void test_string(void) da1 = darr_in_strcatf(da1, "0123456789: %08x", 0xDEADBEEF); assert(!strcmp("0123456789: deadbeef", da1)); darr_free(da1); + + sum = 0; + *darr_append(strings) = "1"; + *darr_append(strings) = "2"; + *darr_append(strings) = "3"; +#define adder(x) (sum += atoi(x)) + darr_free_func(strings, adder); + assert(sum == 6); + assert(strings == NULL); + + sum = 0; + darr_free_func(strings, adder); + assert(sum == 0); + assert(strings == NULL); + + *darr_append(strings) = NULL; + *darr_append(strings) = darr_strdup("2"); + *darr_append(strings) = darr_strdup("3"); + darr_free_free(strings); + assert(strings == NULL); + + darr_free_free(strings); + assert(strings == NULL); } int main(int argc, char **argv) |
