2 * Copyright © 2009 Dan Nicholson
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
30 #define DATA_PATH "keymaps/stringcomp.data"
33 main(int argc, char *argv[])
35 struct xkb_context *ctx = test_get_context();
36 struct xkb_keymap *keymap;
37 char *original, *dump;
41 /* Load in a prebuilt keymap, make sure we can compile it from a string,
42 * then compare it to make sure we get the same result when dumping it
44 original = test_read_file(DATA_PATH);
47 keymap = test_compile_string(ctx, original);
50 dump = xkb_keymap_get_as_string(keymap);
53 if (!streq(original, dump)) {
55 "round-trip test failed: dumped map differs from original\n");
56 fprintf(stderr, "path to original file: %s\n",
57 test_get_path(DATA_PATH));
58 fprintf(stderr, "length: dumped %zu, original %zu\n",
59 strlen(dump), strlen(original));
60 fprintf(stderr, "dumped map:\n");
61 fprintf(stderr, "%s\n", dump);
68 xkb_keymap_unref(keymap);
70 /* Make sure we can't (falsely claim to) compile an empty string. */
71 keymap = test_compile_string(ctx, "");
74 xkb_context_unref(ctx);