| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#include "testutils.h" |
| 24 |
|
| 25 |
# define NPL_TESTING |
| 26 |
# include "../lib/files.c" |
| 27 |
# undef NPL_TESTING |
| 28 |
|
| 29 |
typedef struct test_data |
| 30 |
{ |
| 31 |
char *value; |
| 32 |
bool expect_value; |
| 33 |
} test_data; |
| 34 |
|
| 35 |
static int |
| 36 |
test_files_is_hidden (const void *tdata) |
| 37 |
{ |
| 38 |
const struct test_data *data = tdata; |
| 39 |
int ret = 0; |
| 40 |
|
| 41 |
bool check = files_is_hidden (data->value); |
| 42 |
TEST_ASSERT_EQUAL_NUMERIC (check, data->expect_value); |
| 43 |
return ret; |
| 44 |
} |
| 45 |
|
| 46 |
static int |
| 47 |
mymain (void) |
| 48 |
{ |
| 49 |
int ret = 0; |
| 50 |
|
| 51 |
# define DO_TEST(VALUE, EXPECT_VALUE) \ |
| 52 |
do \ |
| 53 |
{ \ |
| 54 |
test_data data = { \ |
| 55 |
.value = VALUE, \ |
| 56 |
.expect_value = EXPECT_VALUE, \ |
| 57 |
}; \ |
| 58 |
if (test_run("check function files_is_hidden against " VALUE, \ |
| 59 |
test_files_is_hidden, (&data)) < 0) \ |
| 60 |
ret = -1; \ |
| 61 |
} \ |
| 62 |
while (0) |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
DO_TEST (".hiddenfile", true); |
| 67 |
DO_TEST ("anotherfile", false); |
| 68 |
|
| 69 |
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; |
| 70 |
} |
| 71 |
|
| 72 |
TEST_MAIN (mymain) |