#include <stdlib.h>
#include <check.h>
#include "ccsds.h"

int debug = 15;

void setup(void)
{
    // Open files, clean up logs, etc.
}

START_TEST (test_create)
{
  char* msg;
  msg = ccsds_dump(NULL);
  fail_unless(strcmp(msg, "Test") == 0,
              "An error in ccsds_dump() function");
  free(msg);
}
END_TEST

void testdown(void)
{
    // Clean up
}

Suite *ccsds_suite(void)
{
  // Create suite, which has multiple testcases
  Suite *s = suite_create("ccsds");

  // Create testcase, which has multiple tests
  TCase *tc_core = tcase_create("ccsds_1");

  // Add testcase to suite
  suite_add_tcase (s, tc_core);

  // Add test to testcase
  tcase_add_test(tc_core, test_create);

  return s;
}

int main(void)
{
  int nf;

  // Create suite
  Suite *s = ccsds_suite();

  // Create runner and attach suite
  SRunner *sr = srunner_create(s);

  // Execute runner in Fork mode (CK_NORMAL, CK_NOFORK)
  srunner_run_all(sr, CK_NORMAL);

  // Retrieve number of failed tests
  nf = srunner_ntests_failed(sr);

  // Clean up
  srunner_free(sr);
  return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}

