| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#include <stdlib.h> |
| 24 |
#include "testutils.h" |
| 25 |
|
| 26 |
typedef struct test_data |
| 27 |
{ |
| 28 |
char * filename; |
| 29 |
size_t expect_size; |
| 30 |
} test_data; |
| 31 |
|
| 32 |
static int |
| 33 |
test_fstringify_bufsize (const void *tdata) |
| 34 |
{ |
| 35 |
int ret = 0; |
| 36 |
const struct test_data *data = tdata; |
| 37 |
|
| 38 |
char * buffer = test_fstringify (data->filename); |
| 39 |
if (NULL == buffer) |
| 40 |
return -1; |
| 41 |
|
| 42 |
TEST_ASSERT_EQUAL_NUMERIC (data->expect_size, strlen (buffer)); |
| 43 |
|
| 44 |
free (buffer); |
| 45 |
return ret; |
| 46 |
} |
| 47 |
|
| 48 |
static int |
| 49 |
mymain (void) |
| 50 |
{ |
| 51 |
int ret = 0; |
| 52 |
char *filename = NPL_TEST_PATH_CONTAINER_JSON; |
| 53 |
|
| 54 |
#define DO_TEST(MSG, FILENAME, EXPECT_SIZE) \ |
| 55 |
do \ |
| 56 |
{ \ |
| 57 |
test_data data = { \ |
| 58 |
.filename = FILENAME, \ |
| 59 |
.expect_size = EXPECT_SIZE, \ |
| 60 |
}; \ |
| 61 |
if (test_run(MSG, test_fstringify_bufsize, &data) < 0) \ |
| 62 |
ret = -1; \ |
| 63 |
} \ |
| 64 |
while (0) |
| 65 |
|
| 66 |
DO_TEST ("checking test_fstringify ()", filename, 3832); |
| 67 |
|
| 68 |
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; |
| 69 |
} |
| 70 |
|
| 71 |
TEST_MAIN (mymain) |