mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 12:22:12 +00:00
Added starting files for check unit tests
This commit is contained in:
parent
96d9751300
commit
b635adc096
3
c-check/.gitignore
vendored
Normal file
3
c-check/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
*.o
|
||||
test_gildedrose
|
||||
golden_rose
|
||||
@ -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})
|
||||
|
||||
|
||||
31
c-check/test_main.c
Normal file
31
c-check/test_main.c
Normal file
@ -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;
|
||||
}
|
||||
34
c-check/test_rose.c
Normal file
34
c-check/test_rose.c
Normal file
@ -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;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user