mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 20:32:15 +00:00
Reverted files to a useful starting point
This commit is contained in:
parent
20178c8026
commit
3200f2e36c
7
c-check/.gitignore
vendored
7
c-check/.gitignore
vendored
@ -1,3 +1,10 @@
|
||||
*.o
|
||||
*.gch
|
||||
*.config
|
||||
*.creator
|
||||
*.creator.user
|
||||
*.files
|
||||
*.includes
|
||||
*.iml
|
||||
test_gildedrose
|
||||
golden_rose
|
||||
|
||||
@ -1,69 +0,0 @@
|
||||
#include <check.h>
|
||||
#include "GildedRose.h"
|
||||
|
||||
#define GOOD_BACKSTAGE "Backstage passes to a TAFKAL80ETC concert"
|
||||
#define BAD_BACKSTAGE "Backstage passes to a Jeff Beck concert"
|
||||
|
||||
START_TEST(backstage_whenMoreThan10Days_increasesByOne)
|
||||
{
|
||||
Item items[1];
|
||||
init_item(items, GOOD_BACKSTAGE, 12, 15);
|
||||
update_quality(items, 1);
|
||||
|
||||
ck_assert_int_eq(16, items[0].quality);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(backstage_when10Days_increasesByTwo)
|
||||
{
|
||||
Item items[1];
|
||||
init_item(items, GOOD_BACKSTAGE, 10, 15);
|
||||
update_quality(items, 1);
|
||||
|
||||
ck_assert_int_eq(17, items[0].quality);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(backstage_when5Days_increasesByThree)
|
||||
{
|
||||
Item items[1];
|
||||
init_item(items, GOOD_BACKSTAGE, 5, 15);
|
||||
update_quality(items, 1);
|
||||
|
||||
ck_assert_int_eq(18, items[0].quality);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(backstage_when0Days_hasQualityZero)
|
||||
{
|
||||
Item items[1];
|
||||
init_item(items, GOOD_BACKSTAGE, 0, 15);
|
||||
update_quality(items, 1);
|
||||
|
||||
ck_assert_int_eq(0, items[0].quality);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(otherBackstage_when12Days_decreasesByOne)
|
||||
{
|
||||
Item items[1];
|
||||
init_item(items, BAD_BACKSTAGE, 12, 15);
|
||||
update_quality(items, 1);
|
||||
|
||||
ck_assert_int_eq(14, items[0].quality);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
TCase *tcase_backstage(void)
|
||||
{
|
||||
TCase *tc;
|
||||
|
||||
tc = tcase_create("backstage-pass");
|
||||
tcase_add_test(tc, backstage_whenMoreThan10Days_increasesByOne);
|
||||
tcase_add_test(tc, backstage_when10Days_increasesByTwo);
|
||||
tcase_add_test(tc, backstage_when5Days_increasesByThree);
|
||||
tcase_add_test(tc, backstage_when0Days_hasQualityZero);
|
||||
tcase_add_test(tc, otherBackstage_when12Days_decreasesByOne);
|
||||
|
||||
return tc;
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
#include <check.h>
|
||||
#include "GildedRose.h"
|
||||
|
||||
#define CHEESE "Aged Brie"
|
||||
|
||||
START_TEST(agedBrie_whenSellInPositive_increasesQualityByOne)
|
||||
{
|
||||
Item items[1];
|
||||
init_item(items, CHEESE, 10, 15);
|
||||
update_quality(items, 1);
|
||||
|
||||
ck_assert_int_eq(16, items[0].quality);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(agedBrie_cannotIncreaseQualityAboveFifty)
|
||||
{
|
||||
Item items[1];
|
||||
init_item(items, CHEESE, 10, 50);
|
||||
update_quality(items, 1);
|
||||
|
||||
ck_assert_int_eq(50, items[0].quality);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
TCase *tcase_brie(void)
|
||||
{
|
||||
TCase *tc;
|
||||
|
||||
tc = tcase_create("aged-brie");
|
||||
tcase_add_test(tc, agedBrie_whenSellInPositive_increasesQualityByOne);
|
||||
tcase_add_test(tc, agedBrie_cannotIncreaseQualityAboveFifty);
|
||||
|
||||
return tc;
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <check.h>
|
||||
|
||||
Suite *suite_normal(void);
|
||||
Suite *suite_rose(void);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@ -15,7 +15,7 @@ int main(int argc, char **argv)
|
||||
forkme = 0;
|
||||
}
|
||||
|
||||
s = suite_normal();
|
||||
s = suite_rose();
|
||||
runner = srunner_create(s);
|
||||
|
||||
if (0 == forkme) {
|
||||
|
||||
@ -1,84 +0,0 @@
|
||||
#include <check.h>
|
||||
#include "GildedRose.h"
|
||||
|
||||
#define NORMAL_ITEM "Elixer of Mongoose"
|
||||
|
||||
TCase *tcase_brie(void);
|
||||
TCase *tcase_backstage(void);
|
||||
|
||||
START_TEST(normalitem_whenSellInPositive_decreasesQualityByOne)
|
||||
{
|
||||
Item items[1];
|
||||
init_item(items, NORMAL_ITEM, 10, 15);
|
||||
update_quality(items, 1);
|
||||
|
||||
ck_assert_int_eq(14, items[0].quality);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(normalitem_whenSellIsZero_decreasesQualityByTwo)
|
||||
{
|
||||
Item items[1];
|
||||
init_item(items, NORMAL_ITEM, 0, 15);
|
||||
update_quality(items, 1);
|
||||
|
||||
ck_assert_int_eq(13, items[0].quality);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(normalitem_whenQualityZero_doesNotDecrease)
|
||||
{
|
||||
Item items[1];
|
||||
init_item(items, NORMAL_ITEM, 10, 0);
|
||||
update_quality(items, 1);
|
||||
|
||||
ck_assert_int_eq(0, items[0].quality);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST(normalitem_whenSellInNegative_decreasesByTwo)
|
||||
{
|
||||
Item items[1];
|
||||
init_item(items, NORMAL_ITEM, -1, 20);
|
||||
update_quality(items, 1);
|
||||
|
||||
ck_assert_int_eq(18, items[0].quality);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(normalitem_whenSellInZero_decreasesByTwo)
|
||||
{
|
||||
Item items[1];
|
||||
init_item(items, NORMAL_ITEM, -1, 15);
|
||||
update_quality(items, 1);
|
||||
|
||||
ck_assert_int_eq(13, items[0].quality);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
TCase *tcase_normal(void)
|
||||
{
|
||||
TCase *tc;
|
||||
|
||||
tc = tcase_create("normal-items");
|
||||
tcase_add_test(tc, normalitem_whenSellInPositive_decreasesQualityByOne);
|
||||
tcase_add_test(tc, normalitem_whenSellIsZero_decreasesQualityByTwo);
|
||||
tcase_add_test(tc, normalitem_whenQualityZero_doesNotDecrease);
|
||||
tcase_add_test(tc, normalitem_whenSellInNegative_decreasesByTwo);
|
||||
tcase_add_test(tc, normalitem_whenSellInZero_decreasesByTwo);
|
||||
|
||||
return tc;
|
||||
}
|
||||
|
||||
Suite *suite_normal(void)
|
||||
{
|
||||
Suite *s;
|
||||
|
||||
s = suite_create("characterization-tests");
|
||||
suite_add_tcase(s, tcase_normal());
|
||||
suite_add_tcase(s, tcase_brie());
|
||||
suite_add_tcase(s, tcase_backstage());
|
||||
|
||||
return s;
|
||||
}
|
||||
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