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