tests.c 917 Bytes
Newer Older
1 2 3
/* See LICENSE file for license and copyright information */

#include <check.h>
4
#include <stdlib.h>
Sebastian Ramacher's avatar
Sebastian Ramacher committed
5
#include <gtk/gtk.h>
6

Moritz Lipp's avatar
Moritz Lipp committed
7 8 9 10 11 12 13 14 15 16 17 18 19
#define LENGTH(x) (sizeof(x)/sizeof((x)[0]))

extern Suite* suite_session();
extern Suite* suite_utils();
extern Suite* suite_document();

typedef Suite* (*suite_create_fnt_t)(void);

const suite_create_fnt_t suites[] = {
  suite_utils,
  suite_document,
  suite_session,
};
20

Moritz Lipp's avatar
Moritz Lipp committed
21 22
int
main(int argc, char* argv[])
23 24 25
{
  Suite* suite          = NULL;
  SRunner* suite_runner = NULL;
26
  int number_failed = 0;
27

Moritz Lipp's avatar
Moritz Lipp committed
28 29 30
  /* init gtk */
  gtk_init(&argc, &argv);

Moritz Lipp's avatar
Moritz Lipp committed
31 32 33 34 35 36 37 38
  /* run test suites */
  for (unsigned int i = 0; i < LENGTH(suites); i++) {
    suite = suites[i]();
    suite_runner = srunner_create(suite);
    srunner_run_all(suite_runner, CK_NORMAL);
    number_failed += srunner_ntests_failed(suite_runner);
    srunner_free(suite_runner);
  }
39

40
  return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
41
}