check_check_log_internal.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Check: a unit test framework for C
  3. * Copyright (C) 2001, 2002 Arien Malec
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the
  17. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
  18. * MA 02110-1301, USA.
  19. */
  20. #include "../lib/libcompat.h"
  21. /* Tests for log related stuff in check which need non-exported functions. */
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <check.h>
  26. #include <check_list.h>
  27. #include <check_impl.h>
  28. #include <check_log.h>
  29. #include "check_check.h"
  30. #if ENABLE_SUBUNIT
  31. START_TEST(test_init_logging_subunit)
  32. {
  33. /* init_logging with CK_SUBUNIT sets stdout
  34. * to a subunit function, not any log.
  35. */
  36. Log * first_log = NULL;
  37. Suite *s = suite_create("Suite");
  38. SRunner *sr = srunner_create(s);
  39. srunner_init_logging(sr, CK_SUBUNIT);
  40. check_list_front (sr->loglst);
  41. ck_assert_msg (!check_list_at_end(sr->loglst), "No entries in log list");
  42. first_log = (Log *)check_list_val(sr->loglst);
  43. ck_assert_msg (first_log != NULL, "log is NULL");
  44. check_list_advance(sr->loglst);
  45. ck_assert_msg(check_list_at_end(sr->loglst), "More than one entry in log list");
  46. ck_assert_msg(first_log->lfun == subunit_lfun,
  47. "Log function is not the subunit lfun.");
  48. srunner_end_logging(sr);
  49. srunner_free(sr);
  50. }
  51. END_TEST
  52. #endif
  53. Suite *make_log_internal_suite(void)
  54. {
  55. Suite *s;
  56. #if ENABLE_SUBUNIT
  57. TCase *tc_core_subunit;
  58. s = suite_create("Log");
  59. tc_core_subunit = tcase_create("Core SubUnit");
  60. suite_add_tcase(s, tc_core_subunit);
  61. tcase_add_test(tc_core_subunit, test_init_logging_subunit);
  62. #else
  63. s = suite_create("Log");
  64. #endif
  65. return s;
  66. }