X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=tests%2Fcheck_output_all.c;h=1eadea193badd624b24c0db575ba4e8592512d20;hb=390795c0999ae3a41b97f9a8e2c154c81e6d064e;hp=05b65b76e4c5c5898a5d01026d957ff346ed37a2;hpb=6592c3699509213395fa80af5b37f2e4db25ac38;p=libsigrok.git diff --git a/tests/check_output_all.c b/tests/check_output_all.c index 05b65b76..1eadea19 100644 --- a/tests/check_output_all.c +++ b/tests/check_output_all.c @@ -26,13 +26,76 @@ /* Check whether at least one output module is available. */ START_TEST(test_output_available) { - struct sr_output_format **outputs; + const struct sr_output_module **outputs; outputs = sr_output_list(); fail_unless(outputs != NULL, "No output modules found."); } END_TEST +/* Check whether sr_output_id_get() works. */ +START_TEST(test_output_id) +{ + const struct sr_output_module **outputs; + const char *id; + + outputs = sr_output_list(); + + id = sr_output_id_get(outputs[0]); + fail_unless(id != NULL, "No id found in output module."); +} +END_TEST + +/* Check whether sr_output_name_get() works. */ +START_TEST(test_output_name) +{ + const struct sr_output_module **outputs; + const char *name; + + outputs = sr_output_list(); + + name = sr_output_name_get(outputs[0]); + fail_unless(name != NULL, "No name found in output module."); +} +END_TEST + +/* Check whether sr_output_description_get() works. */ +START_TEST(test_output_desc) +{ + const struct sr_output_module **outputs; + const char *desc; + + outputs = sr_output_list(); + + desc = sr_output_description_get(outputs[0]); + fail_unless(desc != NULL, "No description found in output module."); +} +END_TEST + +/* Check whether sr_output_find() works. */ +START_TEST(test_output_find) +{ + const struct sr_output_module *omod; + const char *id; + + omod = sr_output_find("bits"); + fail_unless(omod != NULL, "Couldn't find the 'bits' output module."); + id = sr_output_id_get(omod); + fail_unless(!strcmp(id, "bits"), "That is not the 'bits' module!"); +} +END_TEST + +/* Check whether sr_output_options_get() works. */ +START_TEST(test_output_options) +{ + const struct sr_option **opt; + + opt = sr_output_options_get(sr_output_find("bits")); + fail_unless(opt != NULL, "Couldn't find 'bits' options."); + fail_unless(!strcmp((*opt)->id, "width"), "Wrong 'bits' option found!"); +} +END_TEST + Suite *suite_output_all(void) { Suite *s; @@ -42,6 +105,11 @@ Suite *suite_output_all(void) tc = tcase_create("basic"); tcase_add_test(tc, test_output_available); + tcase_add_test(tc, test_output_id); + tcase_add_test(tc, test_output_name); + tcase_add_test(tc, test_output_desc); + tcase_add_test(tc, test_output_find); + tcase_add_test(tc, test_output_options); suite_add_tcase(s, tc); return s;