From cef6cabce7ae97e9edfb6821ce4393d714579866 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Fri, 17 Jan 2025 11:28:50 -0500 Subject: Incorporate libalabaster changes, Windows fixes Signed-off-by: Andrew Opalach --- tests/fs_event_local.c | 12 +++++++----- tests/meson.build | 1 + tests/misc_file.c | 20 ++++++++++++++++++++ tests/stdin_lines.c | 6 +++--- 4 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 tests/misc_file.c (limited to 'tests') 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 #include -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 +#include + +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); -- cgit v1.2.3-101-g0448