]> sigrok.org Git - libsigrok.git/blame - tests/transform_all.c
tests/analog: add more tests for analog feed to float array conversion
[libsigrok.git] / tests / transform_all.c
CommitLineData
8677e4e7
UH
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2015 Uwe Hermann <uwe@hermann-uwe.de>
5 *
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.
10 *
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.
15 *
16 * You should have received a copy of the GNU General Public License
2ea1fdf1 17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
8677e4e7
UH
18 */
19
6ec6c43b 20#include <config.h>
8677e4e7
UH
21#include <stdlib.h>
22#include <check.h>
4960aeb0 23#include <libsigrok/libsigrok.h>
8677e4e7
UH
24#include "lib.h"
25
26/* Check whether at least one transform module is available. */
27START_TEST(test_transform_available)
28{
29 const struct sr_transform_module **transforms;
30
31 transforms = sr_transform_list();
32 fail_unless(transforms != NULL, "No transform modules found.");
33}
34END_TEST
35
36/* Check whether sr_transform_id_get() works. */
37START_TEST(test_transform_id)
38{
39 const struct sr_transform_module **transforms;
40 const char *id;
41
42 transforms = sr_transform_list();
43
44 id = sr_transform_id_get(transforms[0]);
45 fail_unless(id != NULL, "No ID found in transform module.");
46}
47END_TEST
48
49/* Check whether sr_transform_name_get() works. */
50START_TEST(test_transform_name)
51{
52 const struct sr_transform_module **transforms;
53 const char *name;
54
55 transforms = sr_transform_list();
56
57 name = sr_transform_name_get(transforms[0]);
58 fail_unless(name != NULL, "No name found in transform module.");
59}
60END_TEST
61
62/* Check whether sr_transform_description_get() works. */
63START_TEST(test_transform_desc)
64{
65 const struct sr_transform_module **transforms;
66 const char *desc;
67
68 transforms = sr_transform_list();
69
70 desc = sr_transform_description_get(transforms[0]);
71 fail_unless(desc != NULL, "No description found in transform module.");
72}
73END_TEST
74
75/* Check whether sr_transform_find() works. */
76START_TEST(test_transform_find)
77{
78 const struct sr_transform_module *tmod;
79 const char *id;
80
81 tmod = sr_transform_find("nop");
82 fail_unless(tmod != NULL, "Couldn't find the 'nop' transform module.");
83 id = sr_transform_id_get(tmod);
84 fail_unless(id != NULL, "No ID found in transform module.");
85 fail_unless(!strcmp(id, "nop"), "That is not the 'nop' module!");
86}
87END_TEST
88
89/* Check whether sr_transform_options_get() works. */
90START_TEST(test_transform_options)
91{
92 const struct sr_option **opt;
93
94 opt = sr_transform_options_get(sr_transform_find("nop"));
95 fail_unless(opt == NULL, "Transform module 'nop' doesn't have options.");
96}
97END_TEST
98
99Suite *suite_transform_all(void)
100{
101 Suite *s;
102 TCase *tc;
103
104 s = suite_create("transform-all");
105
106 tc = tcase_create("basic");
107 tcase_add_test(tc, test_transform_available);
108 tcase_add_test(tc, test_transform_id);
109 tcase_add_test(tc, test_transform_name);
110 tcase_add_test(tc, test_transform_desc);
111 tcase_add_test(tc, test_transform_find);
112 tcase_add_test(tc, test_transform_options);
113 suite_add_tcase(s, tc);
114
115 return s;
116}