Compartmentisation of tests, add testing of exception_t
This commit is contained in:
parent
208cb375e1
commit
84cf1b0818
@ -1,11 +1,22 @@
|
||||
bin_PROGRAMS = modetw
|
||||
lib_LTLIBRARIES = libfile_t.la
|
||||
lib_LTLIBRARIES = libmodetw.la
|
||||
|
||||
modetw_SOURCES = main.c calibrate.c exception_t.c file_t.c conf.c
|
||||
modetw_CPPFLAGS = $(XML_CPPFLAGS)
|
||||
modetw_CFLAGS = $(GLIB_CFLAGS)
|
||||
modetw_LDFLAGS= $(XML_LIBS) $(GLIB_LIBS)
|
||||
CFILES = \
|
||||
exception_t.c \
|
||||
file_t.c \
|
||||
calibrate.c \
|
||||
conf.c
|
||||
HFILES = \
|
||||
exception_t.h \
|
||||
file_t.h \
|
||||
calibrate.h \
|
||||
conf.h
|
||||
|
||||
libfile_t_la_SOURCES = file_t.c file_t.h
|
||||
modetw_SOURCES = main.c
|
||||
modetw_LDADD = libmodetw.la
|
||||
|
||||
libmodetw_la_SOURCES = $(CFILES) $(HFILES)
|
||||
libmodetw_la_CPPFLAGS = $(XML_CPPFLAGS)
|
||||
libmodetw_la_CFLAGS = $(GLIB_CFLAGS)
|
||||
libmodetw_la_LDFLAGS= $(XML_LIBS) $(GLIB_LIBS)
|
||||
|
||||
modetw_LDADD = libfile_t.la
|
||||
|
@ -1,5 +1,13 @@
|
||||
TESTS = check_file_t
|
||||
check_PROGRAMS = check_file_t
|
||||
check_file_t_SOURCES = check_file_t.c $(top_builddir)/src/file_t.h
|
||||
check_file_t_CFLAGS= $(CFLAGS) $(CHECK_CFLAGS)
|
||||
check_file_t_LDADD = $(top_builddir)/src/libfile_t.la $(LDFLAGS) $(CHECK_LIBS)
|
||||
TESTS = \
|
||||
check_check
|
||||
|
||||
noinst_PROGRAMS = \
|
||||
check_check
|
||||
|
||||
check_check_SOURCES = \
|
||||
check_file_t.c \
|
||||
check_exception_t.c \
|
||||
check_check.c
|
||||
check_check_CFLAGS= $(CFLAGS) $(CHECK_CFLAGS)
|
||||
check_check_LDFLAGS= $(LDFLAGS) $(CHECK_LIBS)
|
||||
check_check_LDADD = $(top_builddir)/src/libmodetw.la
|
||||
|
17
tests/check_check.c
Normal file
17
tests/check_check.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include <check.h>
|
||||
#include "check_check.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int number_failed;
|
||||
SRunner *sr;
|
||||
|
||||
sr = srunner_create(file_t_suite());
|
||||
srunner_add_suite(sr, exception_t_suite());
|
||||
|
||||
srunner_run_all(sr, CK_VERBOSE);
|
||||
number_failed = srunner_ntests_failed(sr);
|
||||
srunner_free(sr);
|
||||
return number_failed;
|
||||
}
|
9
tests/check_check.h
Normal file
9
tests/check_check.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef CHECK_CHECK_H
|
||||
#define CHECK_CHECK_H
|
||||
|
||||
#include <check.h>
|
||||
|
||||
Suite* file_t_suite(void);
|
||||
Suite* exception_t_suite(void);
|
||||
|
||||
#endif
|
28
tests/check_exception_t.c
Normal file
28
tests/check_exception_t.c
Normal file
@ -0,0 +1,28 @@
|
||||
#include "check_check.h"
|
||||
#include "../src/exception_t.h"
|
||||
|
||||
START_TEST(test_exception_init)
|
||||
{
|
||||
exception_t *e = NULL;
|
||||
e = exception_init();
|
||||
ck_assert_ptr_nonnull(e);
|
||||
ck_assert_int_eq(e->type, NO_ERROR);
|
||||
ck_assert_ptr_null(e->msg);
|
||||
exception_free(e);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
Suite*
|
||||
exception_t_suite(void)
|
||||
{
|
||||
Suite *s;
|
||||
TCase *tc_core;
|
||||
|
||||
s = suite_create ("exception_t");
|
||||
tc_core = tcase_create ("core");
|
||||
|
||||
tcase_add_test(tc_core, test_exception_init);
|
||||
suite_add_tcase(s, tc_core);
|
||||
|
||||
return s;
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
#include <check.h>
|
||||
|
||||
#include "check_check.h"
|
||||
#include "../src/file_t.h"
|
||||
|
||||
START_TEST(test_file_init)
|
||||
@ -41,19 +40,3 @@ file_t_suite(void)
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int number_failed;
|
||||
Suite *s;
|
||||
SRunner *sr;
|
||||
|
||||
s = file_t_suite();
|
||||
sr = srunner_create(s);
|
||||
|
||||
srunner_run_all(sr, CK_VERBOSE);
|
||||
number_failed = srunner_ntests_failed(sr);
|
||||
srunner_free(sr);
|
||||
return number_failed;
|
||||
}
|
||||
|
Reference in New Issue
Block a user