|
Packit Service |
50ad14 |
#include <stdio.h>
|
|
Packit Service |
50ad14 |
#include <stdlib.h>
|
|
Packit Service |
50ad14 |
#include <check.h>
|
|
Packit Service |
50ad14 |
#include <keymap.h>
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
START_TEST(test0)
|
|
Packit Service |
50ad14 |
{
|
|
Packit Service |
50ad14 |
char *s;
|
|
Packit Service |
50ad14 |
lkfile_t f;
|
|
Packit Service |
50ad14 |
struct lk_ctx *ctx;
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
ctx = lk_init();
|
|
Packit Service |
50ad14 |
lk_set_log_fn(ctx, NULL, NULL);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
f.pipe = 0;
|
|
Packit Service |
50ad14 |
strcpy(f.pathname, "charset-keymap0.map");
|
|
Packit Service |
50ad14 |
f.fd = fopen(DATADIR "/charset-keymap0.map", "r");
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
fail_if(lk_parse_keymap(ctx, &f) != 0, "Unable to parse keymap");
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
s = lk_get_charset(ctx);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
fail_if(strcmp(s, "iso-8859-2"), "Unable to parse charset");
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
lk_free(ctx);
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
END_TEST
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
START_TEST(test1)
|
|
Packit Service |
50ad14 |
{
|
|
Packit Service |
50ad14 |
char *s;
|
|
Packit Service |
50ad14 |
lkfile_t f;
|
|
Packit Service |
50ad14 |
struct lk_ctx *ctx;
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
ctx = lk_init();
|
|
Packit Service |
50ad14 |
lk_set_log_fn(ctx, NULL, NULL);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
f.pipe = 0;
|
|
Packit Service |
50ad14 |
strcpy(f.pathname, "null");
|
|
Packit Service |
50ad14 |
f.fd = fopen("/dev/null", "r");
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
fail_if(lk_parse_keymap(ctx, &f) != 0, "Unable to parse keymap");
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
s = lk_get_charset(ctx);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
fail_if(s == NULL, "Charset not found");
|
|
Packit Service |
50ad14 |
fail_if(strcmp(s, "iso-8859-1"), "Unable to parse charset");
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
lk_free(ctx);
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
END_TEST
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
static Suite *
|
|
Packit Service |
50ad14 |
libkeymap_suite(void)
|
|
Packit Service |
50ad14 |
{
|
|
Packit Service |
50ad14 |
Suite *s = suite_create("libkeymap");
|
|
Packit Service |
50ad14 |
TCase *tc_core = tcase_create(NULL);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
tcase_add_test(tc_core, test0);
|
|
Packit Service |
50ad14 |
tcase_add_test(tc_core, test1);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
suite_add_tcase(s, tc_core);
|
|
Packit Service |
50ad14 |
return s;
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
int main(void)
|
|
Packit Service |
50ad14 |
{
|
|
Packit Service |
50ad14 |
int number_failed;
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
Suite *s = libkeymap_suite();
|
|
Packit Service |
50ad14 |
SRunner *sr = srunner_create(s);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
srunner_run_all(sr, CK_NORMAL);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
number_failed = srunner_ntests_failed(sr);
|
|
Packit Service |
50ad14 |
srunner_free(sr);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
Packit Service |
50ad14 |
}
|