diff options
| author | 2025-01-17 11:28:50 -0500 | |
|---|---|---|
| committer | 2025-01-17 11:28:50 -0500 | |
| commit | cef6cabce7ae97e9edfb6821ce4393d714579866 (patch) | |
| tree | ddae72f25aa290a47308c7c955fb647cf9d759fe /tests | |
| parent | 86dd8affaff59cf9d2657ad1c04fd62571b9a470 (diff) | |
| download | libnaunet-cef6cabce7ae97e9edfb6821ce4393d714579866.tar.gz libnaunet-cef6cabce7ae97e9edfb6821ce4393d714579866.tar.bz2 libnaunet-cef6cabce7ae97e9edfb6821ce4393d714579866.zip | |
Incorporate libalabaster changes, Windows fixes
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/fs_event_local.c | 12 | ||||
| -rw-r--r-- | tests/meson.build | 1 | ||||
| -rw-r--r-- | tests/misc_file.c | 20 | ||||
| -rw-r--r-- | tests/stdin_lines.c | 6 |
4 files changed, 31 insertions, 8 deletions
diff --git a/tests/fs_event_local.c b/tests/fs_event_local.c index 25cd545..cded733 100644 --- a/tests/fs_event_local.c +++ b/tests/fs_event_local.c @@ -3,7 +3,7 @@ #include <nnwt/fs_event.h> #include <nnwt/file.h> -static str *TEST_FILE_PATH = al_str_c("./test.txt"); +static str TEST_FILE_PATH = al_str_c("./test.txt"); static struct nn_event_loop loop; static struct nn_fs_event fs; @@ -22,12 +22,14 @@ s32 main(void) nn_event_loop_init(&loop); - if (!nn_file_exists(TEST_FILE_PATH)) - nn_file_create(TEST_FILE_PATH); + if (!nn_file_exists(&TEST_FILE_PATH)) { + nn_file_create(&TEST_FILE_PATH); + } - nn_fs_event_init(&fs, TEST_FILE_PATH, NNWT_CLOSE_WRITE, fs_event_callback, NULL); - if (!nn_fs_event_start(&fs, &loop)) + nn_fs_event_init(&fs, &TEST_FILE_PATH, NNWT_CLOSE_WRITE, fs_event_callback, NULL); + if (!nn_fs_event_start(&fs, &loop)) { return EXIT_FAILURE; + } nn_event_loop_run(&loop); diff --git a/tests/meson.build b/tests/meson.build index de795eb..38b2af8 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,6 +1,7 @@ executable('timer_thread', ['timer_thread.c'], dependencies: naunet) executable('timer_loop', ['timer_loop.c'], dependencies: naunet) executable('loop_sleep', ['loop_sleep.c'], dependencies: naunet) +executable('misc_file', ['misc_file.c'], dependencies: naunet) if not is_windows executable('stdin_lines', ['stdin_lines.c'], dependencies: naunet) executable('fs_event', ['fs_event_local.c'], dependencies: naunet) diff --git a/tests/misc_file.c b/tests/misc_file.c new file mode 100644 index 0000000..efbd833 --- /dev/null +++ b/tests/misc_file.c @@ -0,0 +1,20 @@ +#include <nnwt/common.h> +#include <nnwt/file.h> + +s32 main(s32 argc, char *argv[]) +{ + if (!nn_common_init()) return EXIT_FAILURE; + + if (argc < 2) { + al_printf("No argument\n"); + return EXIT_FAILURE; + } + + if (nn_file_exists(&al_str_cr(argv[1]))) { + al_printf("File exists.\n"); + } else { + al_printf("File does not exist.\n"); + } + + return EXIT_SUCCESS; +} diff --git a/tests/stdin_lines.c b/tests/stdin_lines.c index 9656a78..258f3ce 100644 --- a/tests/stdin_lines.c +++ b/tests/stdin_lines.c @@ -7,8 +7,8 @@ static struct nn_line_processor pro; static u8 line_callback(void *userdata, str *line) { (void)userdata; - al_printf("%.*s\n", AL_STR_PRINTF(line)); - if (al_str_eq(line, al_str_c("quit"))) return NNWT_LINE_PROCESSOR_STOP; + al_printf("%.*s\n", al_str_fmt(line)); + if (al_str_eq(line, &al_str_c("quit"))) return NNWT_LINE_PROCESSOR_STOP; return NNWT_LINE_PROCESSOR_CONTINUE; } @@ -20,7 +20,7 @@ s32 main(void) pro.callback = line_callback; pro.userdata = NULL; - nn_line_processor_init(&pro, al_str_c("\n")); + nn_line_processor_init(&pro, &al_str_c("\n")); nn_line_processor_open_fd(&pro, STDIN_FILENO); nn_line_processor_run(&pro, &loop); |