transform_all.c 3.1 KB

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