mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-09 10:06:20 -05:00
test: add a test binary for foot, using the ‘check’ test framework
This commit is contained in:
parent
fd26fadc2c
commit
30709b0968
3 changed files with 76 additions and 0 deletions
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
61
tests/test-foot.c
Normal file
61
tests/test-foot.c
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#include <check.h>
|
||||
#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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue