mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-10-16 19:05:05 +00:00
Added starting files for check unit tests
This commit is contained in:
1 parent
96d9751300
commit
b635adc096
4 files changed
+69
-1
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
*.o
|
||||||
|
test_gildedrose
|
||||||
|
golden_rose
|
||||||
+1
-1
@@ -12,7 +12,7 @@ CFLAGS = `pkg-config --cflags check` -g --std=c99 -D_POSIX_C_SOURCE=200809L
|
|||||||
LIBS = `pkg-config --libs check`
|
LIBS = `pkg-config --libs check`
|
||||||
|
|
||||||
# All files that should be part of your test should start with 'test'
|
# 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_BASE = $(basename ${TEST_SRC})
|
||||||
TEST_OBJECTS = $(addsuffix .o, ${TEST_BASE})
|
TEST_OBJECTS = $(addsuffix .o, ${TEST_BASE})
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <check.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#include <check.h>
|
||||||
|
#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;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user