2 * This file is part of the libsigrokdecode project.
4 * Copyright (C) 2013 Uwe Hermann <uwe@hermann-uwe.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "../libsigrokdecode.h" /* First, to avoid compiler warning. */
26 * Check whether srd_decoder_load_all() works.
27 * If it returns != SRD_OK (or segfaults) this test will fail.
29 START_TEST(test_load_all)
34 ret = srd_decoder_load_all();
35 fail_unless(ret == SRD_OK, "srd_decoder_load_all() failed: %d.", ret);
41 * Check whether srd_decoder_load() works.
42 * If it returns != SRD_OK (or segfaults) this test will fail.
49 ret = srd_decoder_load("uart");
50 fail_unless(ret == SRD_OK, "srd_decoder_load(uart) failed: %d.", ret);
51 ret = srd_decoder_load("spi");
52 fail_unless(ret == SRD_OK, "srd_decoder_load(spi) failed: %d.", ret);
53 ret = srd_decoder_load("usb_signalling");
54 fail_unless(ret == SRD_OK, "srd_decoder_load(usb_signalling) failed: %d.", ret);
60 * Check whether srd_decoder_load() fails for non-existing or bogus PDs.
61 * If it returns SRD_OK (or segfaults) this test will fail.
63 START_TEST(test_load_bogus)
66 fail_unless(srd_decoder_load(NULL) != SRD_OK);
67 fail_unless(srd_decoder_load("") != SRD_OK);
68 fail_unless(srd_decoder_load(" ") != SRD_OK);
69 fail_unless(srd_decoder_load("nonexisting") != SRD_OK);
70 fail_unless(srd_decoder_load("UART") != SRD_OK);
71 fail_unless(srd_decoder_load("UaRt") != SRD_OK);
72 fail_unless(srd_decoder_load("u a r t") != SRD_OK);
73 fail_unless(srd_decoder_load("uart ") != SRD_OK);
74 fail_unless(srd_decoder_load(" uart") != SRD_OK);
75 fail_unless(srd_decoder_load(" uart ") != SRD_OK);
76 fail_unless(srd_decoder_load("uart spi") != SRD_OK);
81 Suite *suite_decoder(void)
86 s = suite_create("decoder");
88 tc = tcase_create("load");
89 tcase_add_test(tc, test_load_all);
90 tcase_add_test(tc, test_load);
91 tcase_add_test(tc, test_load_bogus);
92 suite_add_tcase(s, tc);