diff --git a/meson.build b/meson.build index 39237a33..dbbd0ebc 100644 --- a/meson.build +++ b/meson.build @@ -84,6 +84,7 @@ wayland_cursor = dependency('wayland-cursor') xkb = dependency('xkbcommon', version: '>=1.0.0') fontconfig = dependency('fontconfig') utf8proc = dependency('libutf8proc', required: get_option('grapheme-clustering')) +check = dependency('check', required: false) if utf8proc.found() add_project_arguments('-DFOOT_GRAPHEME_CLUSTERING=1', language: 'c') diff --git a/tests/meson.build b/tests/meson.build index 4fe52c7d..386f99bc 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -6,3 +6,17 @@ config_test = executable( dependencies: [pixman, xkb, fontconfig, fcft, tllist]) test('config', config_test) + +if check.found() + foot_test = executable( + 'test-foot', + 'test-foot.c', + '../config.c', '../config.h', + '../tokenize.c', '../tokenize.h', + '../user-notification.c', '../user-notification.h', + wl_proto_headers, + dependencies: [check, pixman, xkb, fcft], + link_with: [common] + ) + test('foot', foot_test) +endif diff --git a/tests/test-foot.c b/tests/test-foot.c new file mode 100644 index 00000000..7a62270b --- /dev/null +++ b/tests/test-foot.c @@ -0,0 +1,61 @@ +#include +#include "../config.h" +#include "../user-notification.h" + +static struct config conf = {0}; +static user_notifications_t user_notifications = tll_init(); + +static void +conf_setup(void) +{ + memset(&conf, 0, sizeof(conf)); +} + +static void +conf_teardown(void) +{ + config_free(conf); +} + +static void +user_notifications_setup(void) +{ + ck_assert_int_eq(tll_length(user_notifications), 0); +} + +static void +user_notifications_teardown(void) +{ + user_notifications_free(&user_notifications); +} + +START_TEST(config_invalid_path) +{ + bool success = config_load( + &conf, "/invalid-path", &user_notifications, NULL, true); + ck_assert(!success); +} + +static Suite * +foot_suite(void) +{ + Suite *suite = suite_create("foot"); + TCase *config = tcase_create("config"); + tcase_add_checked_fixture(config, &conf_setup, &conf_teardown); + tcase_add_checked_fixture( + config, &user_notifications_setup, &user_notifications_teardown); + tcase_add_test(config, config_invalid_path); + suite_add_tcase(suite, config); + return suite; +} + +int +main(int argc, const char *const *argv) +{ + Suite *suite = foot_suite(); + SRunner *runner = srunner_create(suite); + srunner_run_all(runner, CK_NORMAL); + int failed = srunner_ntests_failed(runner); + srunner_free(runner); + return failed; +}