diff --git a/c-check/.gitignore b/c-check/.gitignore new file mode 100644 index 00000000..52fc06fa --- /dev/null +++ b/c-check/.gitignore @@ -0,0 +1,3 @@ +*.o +test_gildedrose +golden_rose diff --git a/c-check/Makefile b/c-check/Makefile index 6e077a88..1cc056b7 100644 --- a/c-check/Makefile +++ b/c-check/Makefile @@ -12,7 +12,7 @@ CFLAGS = `pkg-config --cflags check` -g --std=c99 -D_POSIX_C_SOURCE=200809L LIBS = `pkg-config --libs check` # All files that should be part of your test should start with 'test' -TEST_SRC = `ls test*.[c\|h]` +TEST_SRC = $(wildcard test*.[c\|h]) TEST_BASE = $(basename ${TEST_SRC}) TEST_OBJECTS = $(addsuffix .o, ${TEST_BASE}) diff --git a/c-check/test_main.c b/c-check/test_main.c new file mode 100644 index 00000000..0d5a0de0 --- /dev/null +++ b/c-check/test_main.c @@ -0,0 +1,31 @@ +#include +#include +#include + +Suite *suite_rose(void); + +int main(int argc, char **argv) +{ + Suite *s; + SRunner *runner; + int number_fails; + int forkme = 1; + + if (argc > 1 && strcmp(argv[1], "--nofork") == 0) { + forkme = 0; + } + + s = suite_rose(); + runner = srunner_create(s); + + if (0 == forkme) { + srunner_set_fork_status(runner, CK_NOFORK); + } + + srunner_run_all(runner, CK_NORMAL); + number_fails = srunner_ntests_failed(runner); + + srunner_free(runner); + + return number_fails; +} diff --git a/c-check/test_rose.c b/c-check/test_rose.c new file mode 100644 index 00000000..30cc7544 --- /dev/null +++ b/c-check/test_rose.c @@ -0,0 +1,34 @@ +#include +#include "GildedRose.h" + + + +START_TEST(roseFoo) +{ + Item items[1]; + init_item(items, "foo", 0, 0); + update_quality(items, 1); + + ck_assert_str_eq("fixme", items[0].name); +} +END_TEST + +TCase *tcase_rose(void) +{ + TCase *tc; + + tc = tcase_create("gilded-rose"); + tcase_add_test(tc, roseFoo); + + return tc; +} + +Suite *suite_rose(void) +{ + Suite *s; + + s = suite_create("characterization-tests"); + suite_add_tcase(s, tcase_rose()); + + return s; +}