2 * This file is part of the libsigrok 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
24 #include <libsigrok/libsigrok.h>
28 * Check the version number API calls and macros.
30 * The numbers returned by the sr_*_version*get() calls must match the
31 * respective SR_*_VERSION* macro values, must be >= 0, and must not be
32 * unreasonably high (> 20), otherwise something is probably wrong.
34 START_TEST(test_version_numbers)
38 ver = sr_package_version_major_get();
39 fail_unless(ver == SR_PACKAGE_VERSION_MAJOR);
40 fail_unless(ver >= 0 && ver <= 20);
41 ver = sr_package_version_minor_get();
42 fail_unless(ver == SR_PACKAGE_VERSION_MINOR);
43 fail_unless(ver >= 0 && ver <= 20);
44 ver = sr_package_version_micro_get();
45 fail_unless(ver == SR_PACKAGE_VERSION_MICRO);
46 fail_unless(ver >= 0 && ver <= 20);
48 ver = sr_lib_version_current_get();
49 fail_unless(ver == SR_LIB_VERSION_CURRENT);
50 fail_unless(ver >= 0 && ver <= 20);
51 ver = sr_lib_version_revision_get();
52 fail_unless(ver == SR_LIB_VERSION_REVISION);
53 fail_unless(ver >= 0 && ver <= 20);
54 ver = sr_lib_version_age_get();
55 fail_unless(ver == SR_LIB_VERSION_AGE);
56 fail_unless(ver >= 0 && ver <= 20);
61 * Check the version number API calls and macros.
63 * The string representations of the package/lib version must match the
64 * version numbers, the string lengths must be >= 5 (e.g. "0.1.0"), and
65 * the strings length must be <= 20 characters, otherwise something is
68 START_TEST(test_version_strings)
72 str = sr_package_version_string_get();
73 fail_unless(str != NULL);
74 fail_unless(strlen(str) >= 5 && strlen(str) <= 20);
75 str = sr_lib_version_string_get();
76 fail_unless(str != NULL);
77 fail_unless(strlen(str) >= 5 && strlen(str) <= 20);
81 Suite *suite_version(void)
86 s = suite_create("version");
88 tc = tcase_create("version");
89 tcase_add_test(tc, test_version_numbers);
90 tcase_add_test(tc, test_version_strings);
91 suite_add_tcase(s, tc);