]>
Commit | Line | Data |
---|---|---|
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 | |
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 | |
19 | */ | |
20 | ||
21 | #include <config.h> | |
22 | #include <stdlib.h> | |
23 | #include <check.h> | |
24 | #include <libsigrok/libsigrok.h> | |
25 | #include "lib.h" | |
26 | ||
27 | /* Check whether at least one transform module is available. */ | |
28 | START_TEST(test_transform_available) | |
29 | { | |
30 | const struct sr_transform_module **transforms; | |
31 | ||
32 | transforms = sr_transform_list(); | |
33 | fail_unless(transforms != NULL, "No transform modules found."); | |
34 | } | |
35 | END_TEST | |
36 | ||
37 | /* Check whether sr_transform_id_get() works. */ | |
38 | START_TEST(test_transform_id) | |
39 | { | |
40 | const struct sr_transform_module **transforms; | |
41 | const char *id; | |
42 | ||
43 | transforms = sr_transform_list(); | |
44 | ||
45 | id = sr_transform_id_get(transforms[0]); | |
46 | fail_unless(id != NULL, "No ID found in transform module."); | |
47 | } | |
48 | END_TEST | |
49 | ||
50 | /* Check whether sr_transform_name_get() works. */ | |
51 | START_TEST(test_transform_name) | |
52 | { | |
53 | const struct sr_transform_module **transforms; | |
54 | const char *name; | |
55 | ||
56 | transforms = sr_transform_list(); | |
57 | ||
58 | name = sr_transform_name_get(transforms[0]); | |
59 | fail_unless(name != NULL, "No name found in transform module."); | |
60 | } | |
61 | END_TEST | |
62 | ||
63 | /* Check whether sr_transform_description_get() works. */ | |
64 | START_TEST(test_transform_desc) | |
65 | { | |
66 | const struct sr_transform_module **transforms; | |
67 | const char *desc; | |
68 | ||
69 | transforms = sr_transform_list(); | |
70 | ||
71 | desc = sr_transform_description_get(transforms[0]); | |
72 | fail_unless(desc != NULL, "No description found in transform module."); | |
73 | } | |
74 | END_TEST | |
75 | ||
76 | /* Check whether sr_transform_find() works. */ | |
77 | START_TEST(test_transform_find) | |
78 | { | |
79 | const struct sr_transform_module *tmod; | |
80 | const char *id; | |
81 | ||
82 | tmod = sr_transform_find("nop"); | |
83 | fail_unless(tmod != NULL, "Couldn't find the 'nop' transform module."); | |
84 | id = sr_transform_id_get(tmod); | |
85 | fail_unless(id != NULL, "No ID found in transform module."); | |
86 | fail_unless(!strcmp(id, "nop"), "That is not the 'nop' module!"); | |
87 | } | |
88 | END_TEST | |
89 | ||
90 | /* Check whether sr_transform_options_get() works. */ | |
91 | START_TEST(test_transform_options) | |
92 | { | |
93 | const struct sr_option **opt; | |
94 | ||
95 | opt = sr_transform_options_get(sr_transform_find("nop")); | |
96 | fail_unless(opt == NULL, "Transform module 'nop' doesn't have options."); | |
97 | } | |
98 | END_TEST | |
99 | ||
100 | Suite *suite_transform_all(void) | |
101 | { | |
102 | Suite *s; | |
103 | TCase *tc; | |
104 | ||
105 | s = suite_create("transform-all"); | |
106 | ||
107 | tc = tcase_create("basic"); | |
108 | tcase_add_test(tc, test_transform_available); | |
109 | tcase_add_test(tc, test_transform_id); | |
110 | tcase_add_test(tc, test_transform_name); | |
111 | tcase_add_test(tc, test_transform_desc); | |
112 | tcase_add_test(tc, test_transform_find); | |
113 | tcase_add_test(tc, test_transform_options); | |
114 | suite_add_tcase(s, tc); | |
115 | ||
116 | return s; | |
117 | } |