File: transform_all.c

package info (click to toggle)
libsigrok 0.5.2-5.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,428 kB
  • sloc: ansic: 89,004; sh: 4,478; cpp: 2,198; makefile: 852; python: 270; java: 13; xml: 8
file content (116 lines) | stat: -rw-r--r-- 3,193 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
 * This file is part of the libsigrok project.
 *
 * Copyright (C) 2015 Uwe Hermann <uwe@hermann-uwe.de>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

#include <config.h>
#include <stdlib.h>
#include <check.h>
#include <libsigrok/libsigrok.h>
#include "lib.h"

/* Check whether at least one transform module is available. */
START_TEST(test_transform_available)
{
	const struct sr_transform_module **transforms;

	transforms = sr_transform_list();
	fail_unless(transforms != NULL, "No transform modules found.");
}
END_TEST

/* Check whether sr_transform_id_get() works. */
START_TEST(test_transform_id)
{
	const struct sr_transform_module **transforms;
	const char *id;

	transforms = sr_transform_list();

	id = sr_transform_id_get(transforms[0]);
	fail_unless(id != NULL, "No ID found in transform module.");
}
END_TEST

/* Check whether sr_transform_name_get() works. */
START_TEST(test_transform_name)
{
	const struct sr_transform_module **transforms;
	const char *name;

	transforms = sr_transform_list();

	name = sr_transform_name_get(transforms[0]);
	fail_unless(name != NULL, "No name found in transform module.");
}
END_TEST

/* Check whether sr_transform_description_get() works. */
START_TEST(test_transform_desc)
{
	const struct sr_transform_module **transforms;
	const char *desc;

	transforms = sr_transform_list();

	desc = sr_transform_description_get(transforms[0]);
	fail_unless(desc != NULL, "No description found in transform module.");
}
END_TEST

/* Check whether sr_transform_find() works. */
START_TEST(test_transform_find)
{
	const struct sr_transform_module *tmod;
	const char *id;

	tmod = sr_transform_find("nop");
	fail_unless(tmod != NULL, "Couldn't find the 'nop' transform module.");
	id = sr_transform_id_get(tmod);
	fail_unless(id != NULL, "No ID found in transform module.");
	fail_unless(!strcmp(id, "nop"), "That is not the 'nop' module!");
}
END_TEST

/* Check whether sr_transform_options_get() works. */
START_TEST(test_transform_options)
{
	const struct sr_option **opt;

	opt = sr_transform_options_get(sr_transform_find("nop"));
	fail_unless(opt == NULL, "Transform module 'nop' doesn't have options.");
}
END_TEST

Suite *suite_transform_all(void)
{
	Suite *s;
	TCase *tc;

	s = suite_create("transform-all");

	tc = tcase_create("basic");
	tcase_add_test(tc, test_transform_available);
	tcase_add_test(tc, test_transform_id);
	tcase_add_test(tc, test_transform_name);
	tcase_add_test(tc, test_transform_desc);
	tcase_add_test(tc, test_transform_find);
	tcase_add_test(tc, test_transform_options);
	suite_add_tcase(s, tc);

	return s;
}