X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=test%2Frules-file.c;h=d217ba960beef7f1cd2dcf1339d375e17839c673;hb=243b0c8703e4339454d7b8e6758ffe6daddbb263;hp=c52ff235d0fc835fd7bcdb469d38c641e0721b41;hpb=3e86ebca0684d90899f34c2add6b1474c464613f;p=platform%2Fupstream%2Flibxkbcommon.git diff --git a/test/rules-file.c b/test/rules-file.c index c52ff23..d217ba9 100644 --- a/test/rules-file.c +++ b/test/rules-file.c @@ -21,14 +21,11 @@ * DEALINGS IN THE SOFTWARE. */ -#include -#include -#include -#include +#include "config.h" -#include "xkbcommon/xkbcommon.h" -#include "rules.h" #include "test.h" +#include "xkbcomp/xkbcomp-priv.h" +#include "xkbcomp/rules.h" struct test_data { /* Rules file */ @@ -50,14 +47,6 @@ struct test_data { bool should_fail; }; -static inline bool -streq(const char *s1, const char *s2) -{ - if (s1 == NULL || s2 == NULL) - return s1 == s2; - return strcmp(s1, s2) == 0; -} - static bool test_rules(struct xkb_context *ctx, struct test_data *data) { @@ -65,54 +54,46 @@ test_rules(struct xkb_context *ctx, struct test_data *data) const struct xkb_rule_names rmlvo = { data->rules, data->model, data->layout, data->variant, data->options }; - struct xkb_component_names *kccgst; + struct xkb_component_names kccgst; fprintf(stderr, "\n\nChecking : %s\t%s\t%s\t%s\t%s\n", data->rules, data->model, data->layout, data->variant, data->options); if (data->should_fail) - fprintf(stderr, "Expecting: NULL\n"); + fprintf(stderr, "Expecting: FAILURE\n"); else fprintf(stderr, "Expecting: %s\t%s\t%s\t%s\n", data->keycodes, data->types, data->compat, data->symbols); - kccgst = xkb_components_from_rules(ctx, &rmlvo); - if (!kccgst) { - fprintf(stderr, "Received: NULL\n"); + if (!xkb_components_from_rules(ctx, &rmlvo, &kccgst)) { + fprintf(stderr, "Received : FAILURE\n"); return data->should_fail; } fprintf(stderr, "Received : %s\t%s\t%s\t%s\n", - kccgst->keycodes, kccgst->types, kccgst->compat, kccgst->symbols); + kccgst.keycodes, kccgst.types, kccgst.compat, kccgst.symbols); - passed = streq(kccgst->keycodes, data->keycodes) && - streq(kccgst->types, data->types) && - streq(kccgst->compat, data->compat) && - streq(kccgst->symbols, data->symbols); + passed = streq(kccgst.keycodes, data->keycodes) && + streq(kccgst.types, data->types) && + streq(kccgst.compat, data->compat) && + streq(kccgst.symbols, data->symbols); - free(kccgst->keycodes); - free(kccgst->types); - free(kccgst->compat); - free(kccgst->symbols); - free(kccgst); + free(kccgst.keycodes); + free(kccgst.types); + free(kccgst.compat); + free(kccgst.symbols); return passed; } int -main(void) +main(int argc, char *argv[]) { struct xkb_context *ctx; - const char *srcdir = getenv("srcdir"); - char *path; - ctx = xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES); + ctx = test_get_context(0); assert(ctx); - assert(asprintf(&path, "%s/test/data", srcdir ? srcdir : ".") > 0); - assert(xkb_context_include_path_append(ctx, test_get_path(""))); - free(path); - struct test_data test1 = { .rules = "simple", @@ -120,7 +101,7 @@ main(void) .options = "my_option", .keycodes = "my_keycodes", .types = "my_types", - .compat = "my_compat+some:compat", + .compat = "my_compat|some:compat", .symbols = "my_symbols+extra_variant", }; assert(test_rules(ctx, &test1));