tests/plover/test-comps.c
author J. Ali Harlow <ali@juiblex.co.uk>
Tue Apr 24 18:49:55 2018 +0100 (2018-04-24)
changeset 67 c9eb7aa21ff4
permissions -rw-r--r--
Release 0.5.3
     1 /*
     2  * Copyright (C) 2016  J. Ali Harlow <ali@juiblex.co.uk>
     3  *
     4  * This program is free software; you can redistribute it and/or modify
     5  * it under the terms of the GNU General Public License as published by
     6  * the Free Software Foundation; either version 2 of the License, or
     7  * (at your option) any later version.
     8  *
     9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License along
    15  * with this program; if not, write to the Free Software Foundation, Inc.,
    16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    17  */
    18 
    19 #include <stdlib.h>
    20 #include <razor.h>
    21 #include <plover/plover.h>
    22 
    23 static void test_basic(void)
    24 {
    25     struct comps *comps;
    26     comps=plover_comps_new();
    27     g_assert(comps);
    28     plover_comps_free(comps);
    29 }
    30 
    31 static void test_from_file(void)
    32 {
    33     struct comps *comps;
    34     struct comps_group *group;
    35     gchar *s;
    36     s=g_build_filename(g_getenv("tests_srcdir"),"comps.xml",NULL);
    37     comps=plover_comps_new_from_file(s);
    38     if (!comps)
    39 	g_error("%s: Failed to read components",s);
    40     g_free(s);
    41     group=plover_comps_lookup_group(comps,"base");
    42     g_assert(group);
    43     g_assert(!plover_comps_lookup_group(comps,"nonexistant"));
    44     plover_comps_free(comps);
    45 }
    46 
    47 int main(int argc,char **argv)
    48 {
    49     int retval;
    50     g_test_init(&argc,&argv,NULL);
    51     g_test_bug_base("mailto:ali@juiblex.co.uk");
    52     g_test_add_func("/comps/basic",test_basic);
    53     g_test_add_func("/comps/from-file",test_from_file);
    54     retval=g_test_run();
    55     return retval;
    56 }