From 96d9751300a02dc3d6f4dbb6fdaa129a0e397ae3 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Fri, 10 Mar 2017 19:22:12 -0500 Subject: [PATCH 01/22] Added C and check library version --- c-check/GildedRose.c | 90 ++++++++++++++++++++++++++++++++++ c-check/GildedRose.h | 9 ++++ c-check/GildedRose.o | Bin 0 -> 5560 bytes c-check/GildedRoseTextTests.c | 43 ++++++++++++++++ c-check/GildedRoseTextTests.o | Bin 0 -> 8408 bytes c-check/Makefile | 46 +++++++++++++++++ c-check/README | 5 ++ c-check/golden_rose | Bin 0 -> 16520 bytes c-check/run-once.sh | 2 + 9 files changed, 195 insertions(+) create mode 100644 c-check/GildedRose.c create mode 100644 c-check/GildedRose.h create mode 100644 c-check/GildedRose.o create mode 100644 c-check/GildedRoseTextTests.c create mode 100644 c-check/GildedRoseTextTests.o create mode 100644 c-check/Makefile create mode 100644 c-check/README create mode 100755 c-check/golden_rose create mode 100755 c-check/run-once.sh diff --git a/c-check/GildedRose.c b/c-check/GildedRose.c new file mode 100644 index 00000000..afb97bbe --- /dev/null +++ b/c-check/GildedRose.c @@ -0,0 +1,90 @@ +#include +#include "GildedRose.h" + +Item* +init_item(Item* item, const char *name, int sellIn, int quality) +{ + item->sellIn = sellIn; + item->quality = quality; + item->name = strdup(name); + + return item; +} + +void update_quality(Item items[], int size) +{ + int i; + + for (i = 0; i < size; i++) + { + if (strcmp(items[i].name, "Aged Brie") && strcmp(items[i].name, "Backstage passes to a TAFKAL80ETC concert")) + { + if (items[i].quality > 0) + { + if (strcmp(items[i].name, "Sulfuras, Hand of Ragnaros")) + { + items[i].quality = items[i].quality - 1; + } + } + } + else + { + if (items[i].quality < 50) + { + items[i].quality = items[i].quality + 1; + + if (!strcmp(items[i].name, "Backstage passes to a TAFKAL80ETC concert")) + { + if (items[i].sellIn < 11) + { + if (items[i].quality < 50) + { + items[i].quality = items[i].quality + 1; + } + } + + if (items[i].sellIn < 6) + { + if (items[i].quality < 50) + { + items[i].quality = items[i].quality + 1; + } + } + } + } + } + + if (strcmp(items[i].name, "Sulfuras, Hand of Ragnaros")) + { + items[i].sellIn = items[i].sellIn - 1; + } + + if (items[i].sellIn < 0) + { + if (strcmp(items[i].name, "Aged Brie")) + { + if (strcmp(items[i].name, "Backstage passes to a TAFKAL80ETC concert")) + { + if (items[i].quality > 0) + { + if (strcmp(items[i].name, "Sulfuras, Hand of Ragnaros")) + { + items[i].quality = items[i].quality - 1; + } + } + } + else + { + items[i].quality = items[i].quality - items[i].quality; + } + } + else + { + if (items[i].quality < 50) + { + items[i].quality = items[i].quality + 1; + } + } + } + } +} diff --git a/c-check/GildedRose.h b/c-check/GildedRose.h new file mode 100644 index 00000000..78d54a08 --- /dev/null +++ b/c-check/GildedRose.h @@ -0,0 +1,9 @@ +typedef struct +{ + char *name; + int sellIn; + int quality; +} Item; + +extern Item* init_item(Item* item, const char *name, int sellIn, int quality); +extern void update_quality(Item items[], int size); diff --git a/c-check/GildedRose.o b/c-check/GildedRose.o new file mode 100644 index 0000000000000000000000000000000000000000..37283c3a3ce974ab2c0ef781f53248918fe66eef GIT binary patch literal 5560 zcmb_fU2Ggz6}~gG-V9l1y|I%tAqb`dN+V_0Yqv2;+Jv>uI^)&8w?uY&Nf;z-(r)d-auwm(^zDt*gZ~ z)OzO+8e^^Ent8!|`He(qvuY}@n=NL3?Lg=!^!M1$yUu?HfK4ku8n4_cbb_m=z6}-F zw5!E<<<``iY5&G-{@Q%`&4k&Sg2Z2IO>{2(MS)tpbG(gFp>yeGU)R(7+lbrvyn;SA zoA6`5YBzR$>E_nOu^2y47D#I`A1C?`Q)(3;O2^^@ajwEB_r!_bE6R0cImRSzkp!C` zfzBsNk8unmfHl%Q96v>IVY|*>i7$Daa&Rs-CSRAo+`OBv^WThDe$RDzy&Mz#YM~Qc zvFrcOm9bP@Qy|oR#kabieE-_5Tg$J$f-x8yEITD*$g4Ub%Z4obv>#Yy$C$T#-|>y0 zZdk_T;K&|eoRe11mE`|sig6XEkS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}OJ`jG_AP$UYyjMN-y11z24EC+UeI>@j~lkLCOy ziSY>#OVXwBLu4XNj$Z>=T>M8VzNiz%$0aGpKL;546nO&4+s`Qe4k@5uMgKTx$Jzgu z0^z$U+Jv3xS3oG}+w`KBS41G|K2P@Y`qjxE=O^04_yzVX5OMXp5Ho*x_6mDZSG>37 vy@$T9k^T3Oi8MKX +#include "GildedRose.h" + +int +print_item(Item *item) +{ + return printf("%s, %d, %d\n", item->name, item->sellIn, item->quality); +} + +int main() +{ + Item items[9]; + int last = 0; + int day; + int index; + + init_item(items + last++, "+5 Dexterity Vest", 10, 20); + init_item(items + last++, "Aged Brie", 2, 0); + init_item(items + last++, "Elixir of the Mongoose", 5, 7); + init_item(items + last++, "Sulfuras, Hand of Ragnaros", 0, 80); + init_item(items + last++, "Sulfuras, Hand of Ragnaros", -1, 80); + init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 15, 20); + init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 10, 49); + init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 5, 49); + // this Conjured item doesn't yet work properly + init_item(items + last++, "Conjured Mana Cake", 3, 6); + + puts("OMGHAI!"); + + for (day = 0; day <= 30; day++) + { + printf("-------- day %d --------\n", day); + printf("name, sellIn, quality\n"); + for(index = 0; index < last; index++) { + print_item(items + index); + } + + printf("\n"); + + update_quality(items, last); + } + return 0; +} diff --git a/c-check/GildedRoseTextTests.o b/c-check/GildedRoseTextTests.o new file mode 100644 index 0000000000000000000000000000000000000000..e1981da6cf3d4fbbed07a94adc15d888405babdb GIT binary patch literal 8408 zcmbtZeT-Dq6~A|8b{NJNssM z?+q?0)ON+Vu2?a}(gqFM*0gF}HG%GjYrHNID{y=*?4%XXwEUrSHC z)t;W*b22?OaB?c$BARV6Y|>LKJ^73D{`F{a3?FacRdCN^twP@yUY-r4OZ#zZywT{w%$J-}NZ-7ayMoYER5U+x@H2Bt7}8 z7~n&gqWTjdwE4)UGtji@tW39|Dg4f2RAC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SJ&v2fhV<&P*C|VkDufLh7<<49zX1z75v{X4Jk(%>LZ8mW6s^`d3O32Y z-To_|Xg*0XRr>0jPC<1}r^-%kPGq0bHi;;R8AVZYx8L`W>(t*X^%Zn4hZLZ|yx^`C-E zT^&ZnUzPuaOW*zdX^#?=&>jD$T>5G~sUZKL(_zD1{$b={gPV^55>xYZ^8tgw`fgZ#AFTSf zDp&P`KZmZfe0A={LjPTtf{SEyE=D|e{MIZK`m9m<<0Opqn#;J$9rnLVALeoZ literal 0 HcmV?d00001 diff --git a/c-check/run-once.sh b/c-check/run-once.sh new file mode 100755 index 00000000..4f6b2303 --- /dev/null +++ b/c-check/run-once.sh @@ -0,0 +1,2 @@ +make +./GildedRoseTextTests From b635adc09661d3dbf27607e6423d0fd10cfd7f2c Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Fri, 10 Mar 2017 19:41:06 -0500 Subject: [PATCH 02/22] Added starting files for check unit tests --- c-check/.gitignore | 3 +++ c-check/Makefile | 2 +- c-check/test_main.c | 31 +++++++++++++++++++++++++++++++ c-check/test_rose.c | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 c-check/.gitignore create mode 100644 c-check/test_main.c create mode 100644 c-check/test_rose.c 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; +} From a114047f8310a8b6f611add66db1f5f5848b7a50 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Fri, 10 Mar 2017 19:47:41 -0500 Subject: [PATCH 03/22] Updated README to address some specifics of this version of the test --- c-check/README | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/c-check/README b/c-check/README index 2bc1f69b..19c992ed 100644 --- a/c-check/README +++ b/c-check/README @@ -1,5 +1,19 @@ run-once.sh runs your tests once Assumptions: - - make and a C++ compiler (like gcc) is installed on your system and is in the PATH - - The CppUTest framework is in the directory CppUTest + - gnu make and a C compiler (like gcc) is installed on your system and is in the PATH + - The check unit testing library is installed on your system (https://libcheck.github.io/check/) + - pkg-config is installed on your system + +Notes: + - This project is tweaked to run on Linux systems, and will mostly work on Macs. + With some changes to the Makefile it can be made to run on BSD systems with + BSD make. An adventurous person could also get it to run on Windows. + - If you are working on a Macintosh computer you cannot run the memtest target, + because valgrind and OS X don't play nice any more. If you want to use the + memory checker OS X does run docker as a first class citizen. + - If you don't have pkg-config on your system, the only changes you'll need to + make are for the requirements of the check library. Mostly you need to + set the appropriate flags for threaded binaries, which may include some + special linker flags. The libcheck documentation will cover what you need + if you want to undertake this change. From d4c62eb984d273f27d8b4023d9267045cc07e25a Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Fri, 10 Mar 2017 19:51:08 -0500 Subject: [PATCH 04/22] Updated docs, removed binaries --- c-check/GildedRose.o | Bin 5560 -> 0 bytes c-check/GildedRoseTextTests.o | Bin 8408 -> 0 bytes c-check/README | 4 +++- c-check/run-once.sh | 2 -- 4 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 c-check/GildedRose.o delete mode 100644 c-check/GildedRoseTextTests.o delete mode 100755 c-check/run-once.sh diff --git a/c-check/GildedRose.o b/c-check/GildedRose.o deleted file mode 100644 index 37283c3a3ce974ab2c0ef781f53248918fe66eef..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5560 zcmb_fU2Ggz6}~gG-V9l1y|I%tAqb`dN+V_0Yqv2;+Jv>uI^)&8w?uY&Nf;z-(r)d-auwm(^zDt*gZ~ z)OzO+8e^^Ent8!|`He(qvuY}@n=NL3?Lg=!^!M1$yUu?HfK4ku8n4_cbb_m=z6}-F zw5!E<<<``iY5&G-{@Q%`&4k&Sg2Z2IO>{2(MS)tpbG(gFp>yeGU)R(7+lbrvyn;SA zoA6`5YBzR$>E_nOu^2y47D#I`A1C?`Q)(3;O2^^@ajwEB_r!_bE6R0cImRSzkp!C` zfzBsNk8unmfHl%Q96v>IVY|*>i7$Daa&Rs-CSRAo+`OBv^WThDe$RDzy&Mz#YM~Qc zvFrcOm9bP@Qy|oR#kabieE-_5Tg$J$f-x8yEITD*$g4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WDy{XiRxxZ!;cfbO~WgMU!~zY2>-l>vh)JPx5W*X0uJd^yXaS3MgHT*8}bH0WT5{{Q7B<1ImQe^8iyh8Yp zhHoH0S8Djz3D0WywS=oWQsb)cXOE`;K8<^)hVLOiDzD1V9i;b7P5*D?N3FL?e~|E> zX!?I4`BxhLCdn^r_}e7Ers409toqfs>f=78=@;p}TBud}50l<`8a|iSsl^(u@|e)@ zKaroc8s0(pfQDa4_-z`#fbdBTw+KI|;US9iK@C^??sql(N|KLh_LfJJiesi zD=3~nYdHQv0qO4=zJc`BI4b}55+0@ZQ1~l^w-b&cx>V=CrJBCVd$)#vkNga4xY~bx z4gVts544wXHLgS%JE-aB=skn`m*UX|_gp01&u=7r25u0JZppPkdNo|-fhE1&V{pHN z)^}w)qBz$sSxF!7rb#$aS}d9IJeG9JQV_j4J5w!~MJHbd9l=|fjBD=#H8dv3wVZ;D zrZo)ys$(k?7>^~h<*_jvZre!*E`Uk6PQnEcj;&;5kC=HEZ}$H$8Q=hO8O$;I?8OIA zFU^mXq^{zzT?9Wolk~zbNUzdFy+}#Nvk#7=&dI8-FC<(WhTW7fzs$H<&*a#~q+k&;C*I9}A4BbFXkl zy2va00|6d!MX!*(l2xnhl>9I-hy~X+?0c2$aejiN-d|x40#h%4$Lh= Date: Fri, 10 Mar 2017 21:08:31 -0500 Subject: [PATCH 05/22] Removed binary that didn't belong here to begin with --- c-check/golden_rose | Bin 16520 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100755 c-check/golden_rose diff --git a/c-check/golden_rose b/c-check/golden_rose deleted file mode 100755 index a7b256d9196e4728c184819fac2be4a123df26a8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16520 zcmeHOYjj-Ibv}1yG`ge5NVaS&L%^4ZgB`5V!w&?;poe9yj0BF6c{G^o(ae=Jcr>HT z!`P(3Ze_DPQ4F|Uu-sJ=ydX^}p9_wGWq%j_Ch{qDy%?+Dd zmo+R~5=tjSExg`j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From: Clay Dowling Date: Fri, 10 Mar 2017 21:13:06 -0500 Subject: [PATCH 06/22] Added golden rule test --- c-check/golden-rule.sh | 6 + c-check/golden_rule.txt | 373 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 379 insertions(+) create mode 100755 c-check/golden-rule.sh create mode 100644 c-check/golden_rule.txt diff --git a/c-check/golden-rule.sh b/c-check/golden-rule.sh new file mode 100755 index 00000000..2ef885a7 --- /dev/null +++ b/c-check/golden-rule.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +OUTFILE = /tmp/golden-dross.txt + +./golden_rose > $(OUTFILE) +diff $(OUTFILE) golden_rule.txt diff --git a/c-check/golden_rule.txt b/c-check/golden_rule.txt new file mode 100644 index 00000000..a04e48ac --- /dev/null +++ b/c-check/golden_rule.txt @@ -0,0 +1,373 @@ +OMGHAI! +-------- day 0 -------- +name, sellIn, quality ++5 Dexterity Vest, 10, 20 +Aged Brie, 2, 0 +Elixir of the Mongoose, 5, 7 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 15, 20 +Backstage passes to a TAFKAL80ETC concert, 10, 49 +Backstage passes to a TAFKAL80ETC concert, 5, 49 +Conjured Mana Cake, 3, 6 + +-------- day 1 -------- +name, sellIn, quality ++5 Dexterity Vest, 9, 19 +Aged Brie, 1, 1 +Elixir of the Mongoose, 4, 6 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 14, 21 +Backstage passes to a TAFKAL80ETC concert, 9, 50 +Backstage passes to a TAFKAL80ETC concert, 4, 50 +Conjured Mana Cake, 2, 5 + +-------- day 2 -------- +name, sellIn, quality ++5 Dexterity Vest, 8, 18 +Aged Brie, 0, 2 +Elixir of the Mongoose, 3, 5 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 13, 22 +Backstage passes to a TAFKAL80ETC concert, 8, 50 +Backstage passes to a TAFKAL80ETC concert, 3, 50 +Conjured Mana Cake, 1, 4 + +-------- day 3 -------- +name, sellIn, quality ++5 Dexterity Vest, 7, 17 +Aged Brie, -1, 4 +Elixir of the Mongoose, 2, 4 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 12, 23 +Backstage passes to a TAFKAL80ETC concert, 7, 50 +Backstage passes to a TAFKAL80ETC concert, 2, 50 +Conjured Mana Cake, 0, 3 + +-------- day 4 -------- +name, sellIn, quality ++5 Dexterity Vest, 6, 16 +Aged Brie, -2, 6 +Elixir of the Mongoose, 1, 3 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 11, 24 +Backstage passes to a TAFKAL80ETC concert, 6, 50 +Backstage passes to a TAFKAL80ETC concert, 1, 50 +Conjured Mana Cake, -1, 1 + +-------- day 5 -------- +name, sellIn, quality ++5 Dexterity Vest, 5, 15 +Aged Brie, -3, 8 +Elixir of the Mongoose, 0, 2 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 10, 25 +Backstage passes to a TAFKAL80ETC concert, 5, 50 +Backstage passes to a TAFKAL80ETC concert, 0, 50 +Conjured Mana Cake, -2, 0 + +-------- day 6 -------- +name, sellIn, quality ++5 Dexterity Vest, 4, 14 +Aged Brie, -4, 10 +Elixir of the Mongoose, -1, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 9, 27 +Backstage passes to a TAFKAL80ETC concert, 4, 50 +Backstage passes to a TAFKAL80ETC concert, -1, 0 +Conjured Mana Cake, -3, 0 + +-------- day 7 -------- +name, sellIn, quality ++5 Dexterity Vest, 3, 13 +Aged Brie, -5, 12 +Elixir of the Mongoose, -2, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 8, 29 +Backstage passes to a TAFKAL80ETC concert, 3, 50 +Backstage passes to a TAFKAL80ETC concert, -2, 0 +Conjured Mana Cake, -4, 0 + +-------- day 8 -------- +name, sellIn, quality ++5 Dexterity Vest, 2, 12 +Aged Brie, -6, 14 +Elixir of the Mongoose, -3, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 7, 31 +Backstage passes to a TAFKAL80ETC concert, 2, 50 +Backstage passes to a TAFKAL80ETC concert, -3, 0 +Conjured Mana Cake, -5, 0 + +-------- day 9 -------- +name, sellIn, quality ++5 Dexterity Vest, 1, 11 +Aged Brie, -7, 16 +Elixir of the Mongoose, -4, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 6, 33 +Backstage passes to a TAFKAL80ETC concert, 1, 50 +Backstage passes to a TAFKAL80ETC concert, -4, 0 +Conjured Mana Cake, -6, 0 + +-------- day 10 -------- +name, sellIn, quality ++5 Dexterity Vest, 0, 10 +Aged Brie, -8, 18 +Elixir of the Mongoose, -5, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 5, 35 +Backstage passes to a TAFKAL80ETC concert, 0, 50 +Backstage passes to a TAFKAL80ETC concert, -5, 0 +Conjured Mana Cake, -7, 0 + +-------- day 11 -------- +name, sellIn, quality ++5 Dexterity Vest, -1, 8 +Aged Brie, -9, 20 +Elixir of the Mongoose, -6, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 4, 38 +Backstage passes to a TAFKAL80ETC concert, -1, 0 +Backstage passes to a TAFKAL80ETC concert, -6, 0 +Conjured Mana Cake, -8, 0 + +-------- day 12 -------- +name, sellIn, quality ++5 Dexterity Vest, -2, 6 +Aged Brie, -10, 22 +Elixir of the Mongoose, -7, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 3, 41 +Backstage passes to a TAFKAL80ETC concert, -2, 0 +Backstage passes to a TAFKAL80ETC concert, -7, 0 +Conjured Mana Cake, -9, 0 + +-------- day 13 -------- +name, sellIn, quality ++5 Dexterity Vest, -3, 4 +Aged Brie, -11, 24 +Elixir of the Mongoose, -8, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 2, 44 +Backstage passes to a TAFKAL80ETC concert, -3, 0 +Backstage passes to a TAFKAL80ETC concert, -8, 0 +Conjured Mana Cake, -10, 0 + +-------- day 14 -------- +name, sellIn, quality ++5 Dexterity Vest, -4, 2 +Aged Brie, -12, 26 +Elixir of the Mongoose, -9, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 1, 47 +Backstage passes to a TAFKAL80ETC concert, -4, 0 +Backstage passes to a TAFKAL80ETC concert, -9, 0 +Conjured Mana Cake, -11, 0 + +-------- day 15 -------- +name, sellIn, quality ++5 Dexterity Vest, -5, 0 +Aged Brie, -13, 28 +Elixir of the Mongoose, -10, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 0, 50 +Backstage passes to a TAFKAL80ETC concert, -5, 0 +Backstage passes to a TAFKAL80ETC concert, -10, 0 +Conjured Mana Cake, -12, 0 + +-------- day 16 -------- +name, sellIn, quality ++5 Dexterity Vest, -6, 0 +Aged Brie, -14, 30 +Elixir of the Mongoose, -11, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -1, 0 +Backstage passes to a TAFKAL80ETC concert, -6, 0 +Backstage passes to a TAFKAL80ETC concert, -11, 0 +Conjured Mana Cake, -13, 0 + +-------- day 17 -------- +name, sellIn, quality ++5 Dexterity Vest, -7, 0 +Aged Brie, -15, 32 +Elixir of the Mongoose, -12, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -2, 0 +Backstage passes to a TAFKAL80ETC concert, -7, 0 +Backstage passes to a TAFKAL80ETC concert, -12, 0 +Conjured Mana Cake, -14, 0 + +-------- day 18 -------- +name, sellIn, quality ++5 Dexterity Vest, -8, 0 +Aged Brie, -16, 34 +Elixir of the Mongoose, -13, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -3, 0 +Backstage passes to a TAFKAL80ETC concert, -8, 0 +Backstage passes to a TAFKAL80ETC concert, -13, 0 +Conjured Mana Cake, -15, 0 + +-------- day 19 -------- +name, sellIn, quality ++5 Dexterity Vest, -9, 0 +Aged Brie, -17, 36 +Elixir of the Mongoose, -14, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -4, 0 +Backstage passes to a TAFKAL80ETC concert, -9, 0 +Backstage passes to a TAFKAL80ETC concert, -14, 0 +Conjured Mana Cake, -16, 0 + +-------- day 20 -------- +name, sellIn, quality ++5 Dexterity Vest, -10, 0 +Aged Brie, -18, 38 +Elixir of the Mongoose, -15, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -5, 0 +Backstage passes to a TAFKAL80ETC concert, -10, 0 +Backstage passes to a TAFKAL80ETC concert, -15, 0 +Conjured Mana Cake, -17, 0 + +-------- day 21 -------- +name, sellIn, quality ++5 Dexterity Vest, -11, 0 +Aged Brie, -19, 40 +Elixir of the Mongoose, -16, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -6, 0 +Backstage passes to a TAFKAL80ETC concert, -11, 0 +Backstage passes to a TAFKAL80ETC concert, -16, 0 +Conjured Mana Cake, -18, 0 + +-------- day 22 -------- +name, sellIn, quality ++5 Dexterity Vest, -12, 0 +Aged Brie, -20, 42 +Elixir of the Mongoose, -17, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -7, 0 +Backstage passes to a TAFKAL80ETC concert, -12, 0 +Backstage passes to a TAFKAL80ETC concert, -17, 0 +Conjured Mana Cake, -19, 0 + +-------- day 23 -------- +name, sellIn, quality ++5 Dexterity Vest, -13, 0 +Aged Brie, -21, 44 +Elixir of the Mongoose, -18, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -8, 0 +Backstage passes to a TAFKAL80ETC concert, -13, 0 +Backstage passes to a TAFKAL80ETC concert, -18, 0 +Conjured Mana Cake, -20, 0 + +-------- day 24 -------- +name, sellIn, quality ++5 Dexterity Vest, -14, 0 +Aged Brie, -22, 46 +Elixir of the Mongoose, -19, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -9, 0 +Backstage passes to a TAFKAL80ETC concert, -14, 0 +Backstage passes to a TAFKAL80ETC concert, -19, 0 +Conjured Mana Cake, -21, 0 + +-------- day 25 -------- +name, sellIn, quality ++5 Dexterity Vest, -15, 0 +Aged Brie, -23, 48 +Elixir of the Mongoose, -20, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -10, 0 +Backstage passes to a TAFKAL80ETC concert, -15, 0 +Backstage passes to a TAFKAL80ETC concert, -20, 0 +Conjured Mana Cake, -22, 0 + +-------- day 26 -------- +name, sellIn, quality ++5 Dexterity Vest, -16, 0 +Aged Brie, -24, 50 +Elixir of the Mongoose, -21, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -11, 0 +Backstage passes to a TAFKAL80ETC concert, -16, 0 +Backstage passes to a TAFKAL80ETC concert, -21, 0 +Conjured Mana Cake, -23, 0 + +-------- day 27 -------- +name, sellIn, quality ++5 Dexterity Vest, -17, 0 +Aged Brie, -25, 50 +Elixir of the Mongoose, -22, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -12, 0 +Backstage passes to a TAFKAL80ETC concert, -17, 0 +Backstage passes to a TAFKAL80ETC concert, -22, 0 +Conjured Mana Cake, -24, 0 + +-------- day 28 -------- +name, sellIn, quality ++5 Dexterity Vest, -18, 0 +Aged Brie, -26, 50 +Elixir of the Mongoose, -23, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -13, 0 +Backstage passes to a TAFKAL80ETC concert, -18, 0 +Backstage passes to a TAFKAL80ETC concert, -23, 0 +Conjured Mana Cake, -25, 0 + +-------- day 29 -------- +name, sellIn, quality ++5 Dexterity Vest, -19, 0 +Aged Brie, -27, 50 +Elixir of the Mongoose, -24, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -14, 0 +Backstage passes to a TAFKAL80ETC concert, -19, 0 +Backstage passes to a TAFKAL80ETC concert, -24, 0 +Conjured Mana Cake, -26, 0 + +-------- day 30 -------- +name, sellIn, quality ++5 Dexterity Vest, -20, 0 +Aged Brie, -28, 50 +Elixir of the Mongoose, -25, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -15, 0 +Backstage passes to a TAFKAL80ETC concert, -20, 0 +Backstage passes to a TAFKAL80ETC concert, -25, 0 +Conjured Mana Cake, -27, 0 + From 26a1251a61cb53f3b62a61e1ea481d86ea0b1483 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Fri, 10 Mar 2017 21:16:02 -0500 Subject: [PATCH 07/22] Added test against changing Item --- c-check/golden-rule.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/c-check/golden-rule.sh b/c-check/golden-rule.sh index 2ef885a7..342dba02 100755 --- a/c-check/golden-rule.sh +++ b/c-check/golden-rule.sh @@ -1,6 +1,7 @@ #!/bin/bash -OUTFILE = /tmp/golden-dross.txt +OUTFILE=/tmp/golden-dross.txt -./golden_rose > $(OUTFILE) -diff $(OUTFILE) golden_rule.txt +./golden_rose > $OUTFILE +diff $OUTFILE golden_rule.txt +git diff GildedRose.h From c01ba7bc7f9c54e5a17ddc28dfeedc2e5ad6a48b Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Fri, 10 Mar 2017 21:21:59 -0500 Subject: [PATCH 08/22] First check for normal items --- c-check/test_rose.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/c-check/test_rose.c b/c-check/test_rose.c index 30cc7544..cb91d270 100644 --- a/c-check/test_rose.c +++ b/c-check/test_rose.c @@ -1,15 +1,16 @@ #include #include "GildedRose.h" +#define NORMAL_ITEM "Elixer of Mongoose" -START_TEST(roseFoo) +START_TEST(normalitem_whenSellInPositive_decreasesQualityByOne) { Item items[1]; - init_item(items, "foo", 0, 0); + init_item(items, NORMAL_ITEM, 10, 15); update_quality(items, 1); - ck_assert_str_eq("fixme", items[0].name); + ck_assert_int_eq(14, items[0].quality); } END_TEST @@ -17,8 +18,8 @@ TCase *tcase_rose(void) { TCase *tc; - tc = tcase_create("gilded-rose"); - tcase_add_test(tc, roseFoo); + tc = tcase_create("normal-items"); + tcase_add_test(tc, normalitem_whenSellInPositive_decreasesQualityByOne); return tc; } From ccabf6e847702278099fa18811621c287e16df05 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Fri, 10 Mar 2017 21:22:50 -0500 Subject: [PATCH 09/22] First check for normal items --- c-check/test_rose.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/c-check/test_rose.c b/c-check/test_rose.c index cb91d270..1bf3fa7d 100644 --- a/c-check/test_rose.c +++ b/c-check/test_rose.c @@ -14,6 +14,16 @@ START_TEST(normalitem_whenSellInPositive_decreasesQualityByOne) } END_TEST +START_TEST(normalitem_whenSellIsZero_decreasesQualityByOne) +{ + Item items[1]; + init_item(items, NORMAL_ITEM, 0, 15); + update_quality(items, 1); + + ck_assert_int_eq(70, items[0].quality); +} +END_TEST + TCase *tcase_rose(void) { TCase *tc; From fe0cad5a7276279d385fd5c7a69997d45efed129 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Fri, 10 Mar 2017 21:24:09 -0500 Subject: [PATCH 10/22] Second test, normal item below zero --- c-check/test_rose.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/c-check/test_rose.c b/c-check/test_rose.c index 1bf3fa7d..9d340104 100644 --- a/c-check/test_rose.c +++ b/c-check/test_rose.c @@ -14,13 +14,13 @@ START_TEST(normalitem_whenSellInPositive_decreasesQualityByOne) } END_TEST -START_TEST(normalitem_whenSellIsZero_decreasesQualityByOne) +START_TEST(normalitem_whenSellIsZero_decreasesQualityByTwo) { Item items[1]; init_item(items, NORMAL_ITEM, 0, 15); update_quality(items, 1); - ck_assert_int_eq(70, items[0].quality); + ck_assert_int_eq(13, items[0].quality); } END_TEST @@ -30,6 +30,7 @@ TCase *tcase_rose(void) tc = tcase_create("normal-items"); tcase_add_test(tc, normalitem_whenSellInPositive_decreasesQualityByOne); + tcase_add_test(tc, normalitem_whenSellIsZero_decreasesQualityByTwo); return tc; } From 08cf17d6bcf9d2e0dba557632dd38d27d5548051 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Fri, 10 Mar 2017 21:31:09 -0500 Subject: [PATCH 11/22] Renamed to reflect actual contents --- c-check/test_main.c | 4 ++-- c-check/test_rose.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/c-check/test_main.c b/c-check/test_main.c index 0d5a0de0..3fb1a1db 100644 --- a/c-check/test_main.c +++ b/c-check/test_main.c @@ -2,7 +2,7 @@ #include #include -Suite *suite_rose(void); +Suite *suite_normal(void); int main(int argc, char **argv) { @@ -15,7 +15,7 @@ int main(int argc, char **argv) forkme = 0; } - s = suite_rose(); + s = suite_normal(); runner = srunner_create(s); if (0 == forkme) { diff --git a/c-check/test_rose.c b/c-check/test_rose.c index 9d340104..98fbab5b 100644 --- a/c-check/test_rose.c +++ b/c-check/test_rose.c @@ -24,6 +24,16 @@ START_TEST(normalitem_whenSellIsZero_decreasesQualityByTwo) } 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 + TCase *tcase_rose(void) { TCase *tc; @@ -31,11 +41,12 @@ TCase *tcase_rose(void) 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); return tc; } -Suite *suite_rose(void) +Suite *suite_normal(void) { Suite *s; From 438a5d661286daedfc44239fa996c6e09bac1f21 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Fri, 10 Mar 2017 21:39:08 -0500 Subject: [PATCH 12/22] Actually rename the test suite --- c-check/{test_rose.c => test_normal.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename c-check/{test_rose.c => test_normal.c} (100%) diff --git a/c-check/test_rose.c b/c-check/test_normal.c similarity index 100% rename from c-check/test_rose.c rename to c-check/test_normal.c From cdb407461b7809771ff245759e5a27d4146c0584 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Fri, 10 Mar 2017 21:50:17 -0500 Subject: [PATCH 13/22] Added tests for aged brie --- c-check/test_brie.c | 35 +++++++++++++++++++++++++++++++++++ c-check/test_normal.c | 6 ++++-- 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 c-check/test_brie.c diff --git a/c-check/test_brie.c b/c-check/test_brie.c new file mode 100644 index 00000000..e0ef714b --- /dev/null +++ b/c-check/test_brie.c @@ -0,0 +1,35 @@ +#include +#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; +} diff --git a/c-check/test_normal.c b/c-check/test_normal.c index 98fbab5b..f6af58c9 100644 --- a/c-check/test_normal.c +++ b/c-check/test_normal.c @@ -3,6 +3,7 @@ #define NORMAL_ITEM "Elixer of Mongoose" +TCase *tcase_brie(void); START_TEST(normalitem_whenSellInPositive_decreasesQualityByOne) { @@ -34,7 +35,7 @@ START_TEST(normalitem_whenQualityZero_doesNotDecrease) } END_TEST -TCase *tcase_rose(void) +TCase *tcase_normal(void) { TCase *tc; @@ -51,7 +52,8 @@ Suite *suite_normal(void) Suite *s; s = suite_create("characterization-tests"); - suite_add_tcase(s, tcase_rose()); + suite_add_tcase(s, tcase_normal()); + suite_add_tcase(s, tcase_brie()); return s; } From 38857a8dc9195707365d46340e5dd82d35a09738 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Fri, 10 Mar 2017 21:52:33 -0500 Subject: [PATCH 14/22] Test for normal items with SellIn less than zero --- c-check/test_normal.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/c-check/test_normal.c b/c-check/test_normal.c index f6af58c9..acf0e0b8 100644 --- a/c-check/test_normal.c +++ b/c-check/test_normal.c @@ -35,6 +35,17 @@ START_TEST(normalitem_whenQualityZero_doesNotDecrease) } 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 + TCase *tcase_normal(void) { TCase *tc; @@ -43,6 +54,7 @@ TCase *tcase_normal(void) 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); return tc; } From 19dcacbf7e3ea4651c8bf2362cad5439ebde92c9 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Fri, 10 Mar 2017 21:53:40 -0500 Subject: [PATCH 15/22] Added test for zero --- c-check/test_normal.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/c-check/test_normal.c b/c-check/test_normal.c index acf0e0b8..30332830 100644 --- a/c-check/test_normal.c +++ b/c-check/test_normal.c @@ -46,6 +46,16 @@ START_TEST(normalitem_whenSellInNegative_decreasesByTwo) } 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; @@ -55,6 +65,7 @@ TCase *tcase_normal(void) 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; } From ceebe400c9aa7dfd0315ef5adf30135ec161f5e9 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Fri, 10 Mar 2017 22:26:15 -0500 Subject: [PATCH 16/22] Added tests for backstage pass --- c-check/test_backstage.c | 37 +++++++++++++++++++++++++++++++++++++ c-check/test_normal.c | 2 ++ 2 files changed, 39 insertions(+) create mode 100644 c-check/test_backstage.c diff --git a/c-check/test_backstage.c b/c-check/test_backstage.c new file mode 100644 index 00000000..ae762be2 --- /dev/null +++ b/c-check/test_backstage.c @@ -0,0 +1,37 @@ +#include +#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 + + +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); + + return tc; +} diff --git a/c-check/test_normal.c b/c-check/test_normal.c index 30332830..2a38e2f1 100644 --- a/c-check/test_normal.c +++ b/c-check/test_normal.c @@ -4,6 +4,7 @@ #define NORMAL_ITEM "Elixer of Mongoose" TCase *tcase_brie(void); +TCase *tcase_backstage(void); START_TEST(normalitem_whenSellInPositive_decreasesQualityByOne) { @@ -77,6 +78,7 @@ Suite *suite_normal(void) 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; } From 264ed0c974e68c4167847bf372f86d401d90ee72 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Fri, 10 Mar 2017 22:42:52 -0500 Subject: [PATCH 17/22] Tests for backstage passes --- c-check/test_backstage.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/c-check/test_backstage.c b/c-check/test_backstage.c index ae762be2..07364a41 100644 --- a/c-check/test_backstage.c +++ b/c-check/test_backstage.c @@ -24,6 +24,35 @@ START_TEST(backstage_when10Days_increasesByTwo) } 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) { @@ -32,6 +61,9 @@ TCase *tcase_backstage(void) 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; } From 20178c8026cea61792d15655b63adba9b24a6ac7 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Sat, 11 Mar 2017 09:06:34 -0500 Subject: [PATCH 18/22] Updated documentation and made Makefile easier for inexperienced C devs --- c-check/Makefile | 12 ++++++++---- c-check/{README => README.md} | 24 ++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 6 deletions(-) rename c-check/{README => README.md} (54%) diff --git a/c-check/Makefile b/c-check/Makefile index 1cc056b7..dabcf6b1 100644 --- a/c-check/Makefile +++ b/c-check/Makefile @@ -11,13 +11,17 @@ 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 = $(wildcard test*.[c\|h]) +# All files that should be part of your test should start with 'test_' +TEST_SRC = $(wildcard test_*.c) TEST_BASE = $(basename ${TEST_SRC}) TEST_OBJECTS = $(addsuffix .o, ${TEST_BASE}) -# If you add more implementation classes, add them to this variable -OBJECT_UNDER_TEST = GildedRose.o +# All files that should be part of your main program should start with 'gilded_' +PROG_SRC = $(wildcard gilded_*.c) +PROG_BASE = $(basename ${PROG_SRC}) +PROG_OBJECTS = $(addsuffix .o, ${PROG_BASE}) + +OBJECT_UNDER_TEST = GildedRose.o ${PROG_OBJECTS} # This is the test application. You can run this program to see your test output TEST_APP = test_gildedrose diff --git a/c-check/README b/c-check/README.md similarity index 54% rename from c-check/README rename to c-check/README.md index afb21a4e..ec2cd02e 100644 --- a/c-check/README +++ b/c-check/README.md @@ -1,13 +1,33 @@ +# Gilded Rose, C99 Edition + The command "make" will build and run your tests, as well as build the program golden_rose, which can serve as the basis for a golden-rule test. -Assumptions: +## Assumptions - gnu make and a C compiler (like gcc) is installed on your system and is in the PATH - The check unit testing library is installed on your system (https://libcheck.github.io/check/) - pkg-config is installed on your system -Notes: +## Usage + - Run `make` to build the program and run all tests + - Files which contain tests should be named `test_*.c` They will automatically + be included in your test suite. + - `GildedRose.h` should not be modified. The Goblin threat is real. + - New program logic may be included in files named `gilded_*.c` which will + automatically be included in both your tests and the final program. + +## Golden Rule tests + - The program `golden_rose` will generate text output. If you capture this + output after your first `make` you can use this as a reference for a golden + rule test. + - You can test your work against this reference by directing the output of your + current golden_rose to a file and using the `diff` utility to compare that + to the reference file you created above. + - To avoid the Goblin threat you can use `git diff GildedRose.h`, which should + have no output if you have left the precious Item structure unchanged. + +## Notes - This project is tweaked to run on Linux systems, and will mostly work on Macs. With some changes to the Makefile it can be made to run on BSD systems with BSD make. An adventurous person could also get it to run on Windows. From 3200f2e36ce743d7d63ad8ee154234e7454fd242 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Mon, 13 Mar 2017 17:48:12 -0400 Subject: [PATCH 19/22] Reverted files to a useful starting point --- c-check/.gitignore | 7 ++++ c-check/test_backstage.c | 69 --------------------------------- c-check/test_brie.c | 35 ----------------- c-check/test_main.c | 4 +- c-check/test_normal.c | 84 ---------------------------------------- c-check/test_rose.c | 34 ++++++++++++++++ 6 files changed, 43 insertions(+), 190 deletions(-) delete mode 100644 c-check/test_backstage.c delete mode 100644 c-check/test_brie.c delete mode 100644 c-check/test_normal.c create mode 100644 c-check/test_rose.c diff --git a/c-check/.gitignore b/c-check/.gitignore index 52fc06fa..65962297 100644 --- a/c-check/.gitignore +++ b/c-check/.gitignore @@ -1,3 +1,10 @@ *.o +*.gch +*.config +*.creator +*.creator.user +*.files +*.includes +*.iml test_gildedrose golden_rose diff --git a/c-check/test_backstage.c b/c-check/test_backstage.c deleted file mode 100644 index 07364a41..00000000 --- a/c-check/test_backstage.c +++ /dev/null @@ -1,69 +0,0 @@ -#include -#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; -} diff --git a/c-check/test_brie.c b/c-check/test_brie.c deleted file mode 100644 index e0ef714b..00000000 --- a/c-check/test_brie.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#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; -} diff --git a/c-check/test_main.c b/c-check/test_main.c index 3fb1a1db..0d5a0de0 100644 --- a/c-check/test_main.c +++ b/c-check/test_main.c @@ -2,7 +2,7 @@ #include #include -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) { diff --git a/c-check/test_normal.c b/c-check/test_normal.c deleted file mode 100644 index 2a38e2f1..00000000 --- a/c-check/test_normal.c +++ /dev/null @@ -1,84 +0,0 @@ -#include -#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; -} 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; +} From 722d8f2bb1ba3f264e84add8c3557318aefef318 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Mon, 13 Mar 2017 17:49:36 -0400 Subject: [PATCH 20/22] Removed files that didn't belong in version control --- c-check/golden-rule.sh | 7 - c-check/golden_rule.txt | 373 ---------------------------------------- 2 files changed, 380 deletions(-) delete mode 100755 c-check/golden-rule.sh delete mode 100644 c-check/golden_rule.txt diff --git a/c-check/golden-rule.sh b/c-check/golden-rule.sh deleted file mode 100755 index 342dba02..00000000 --- a/c-check/golden-rule.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -OUTFILE=/tmp/golden-dross.txt - -./golden_rose > $OUTFILE -diff $OUTFILE golden_rule.txt -git diff GildedRose.h diff --git a/c-check/golden_rule.txt b/c-check/golden_rule.txt deleted file mode 100644 index a04e48ac..00000000 --- a/c-check/golden_rule.txt +++ /dev/null @@ -1,373 +0,0 @@ -OMGHAI! --------- day 0 -------- -name, sellIn, quality -+5 Dexterity Vest, 10, 20 -Aged Brie, 2, 0 -Elixir of the Mongoose, 5, 7 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 15, 20 -Backstage passes to a TAFKAL80ETC concert, 10, 49 -Backstage passes to a TAFKAL80ETC concert, 5, 49 -Conjured Mana Cake, 3, 6 - --------- day 1 -------- -name, sellIn, quality -+5 Dexterity Vest, 9, 19 -Aged Brie, 1, 1 -Elixir of the Mongoose, 4, 6 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 14, 21 -Backstage passes to a TAFKAL80ETC concert, 9, 50 -Backstage passes to a TAFKAL80ETC concert, 4, 50 -Conjured Mana Cake, 2, 5 - --------- day 2 -------- -name, sellIn, quality -+5 Dexterity Vest, 8, 18 -Aged Brie, 0, 2 -Elixir of the Mongoose, 3, 5 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 13, 22 -Backstage passes to a TAFKAL80ETC concert, 8, 50 -Backstage passes to a TAFKAL80ETC concert, 3, 50 -Conjured Mana Cake, 1, 4 - --------- day 3 -------- -name, sellIn, quality -+5 Dexterity Vest, 7, 17 -Aged Brie, -1, 4 -Elixir of the Mongoose, 2, 4 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 12, 23 -Backstage passes to a TAFKAL80ETC concert, 7, 50 -Backstage passes to a TAFKAL80ETC concert, 2, 50 -Conjured Mana Cake, 0, 3 - --------- day 4 -------- -name, sellIn, quality -+5 Dexterity Vest, 6, 16 -Aged Brie, -2, 6 -Elixir of the Mongoose, 1, 3 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 11, 24 -Backstage passes to a TAFKAL80ETC concert, 6, 50 -Backstage passes to a TAFKAL80ETC concert, 1, 50 -Conjured Mana Cake, -1, 1 - --------- day 5 -------- -name, sellIn, quality -+5 Dexterity Vest, 5, 15 -Aged Brie, -3, 8 -Elixir of the Mongoose, 0, 2 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 10, 25 -Backstage passes to a TAFKAL80ETC concert, 5, 50 -Backstage passes to a TAFKAL80ETC concert, 0, 50 -Conjured Mana Cake, -2, 0 - --------- day 6 -------- -name, sellIn, quality -+5 Dexterity Vest, 4, 14 -Aged Brie, -4, 10 -Elixir of the Mongoose, -1, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 9, 27 -Backstage passes to a TAFKAL80ETC concert, 4, 50 -Backstage passes to a TAFKAL80ETC concert, -1, 0 -Conjured Mana Cake, -3, 0 - --------- day 7 -------- -name, sellIn, quality -+5 Dexterity Vest, 3, 13 -Aged Brie, -5, 12 -Elixir of the Mongoose, -2, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 8, 29 -Backstage passes to a TAFKAL80ETC concert, 3, 50 -Backstage passes to a TAFKAL80ETC concert, -2, 0 -Conjured Mana Cake, -4, 0 - --------- day 8 -------- -name, sellIn, quality -+5 Dexterity Vest, 2, 12 -Aged Brie, -6, 14 -Elixir of the Mongoose, -3, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 7, 31 -Backstage passes to a TAFKAL80ETC concert, 2, 50 -Backstage passes to a TAFKAL80ETC concert, -3, 0 -Conjured Mana Cake, -5, 0 - --------- day 9 -------- -name, sellIn, quality -+5 Dexterity Vest, 1, 11 -Aged Brie, -7, 16 -Elixir of the Mongoose, -4, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 6, 33 -Backstage passes to a TAFKAL80ETC concert, 1, 50 -Backstage passes to a TAFKAL80ETC concert, -4, 0 -Conjured Mana Cake, -6, 0 - --------- day 10 -------- -name, sellIn, quality -+5 Dexterity Vest, 0, 10 -Aged Brie, -8, 18 -Elixir of the Mongoose, -5, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 5, 35 -Backstage passes to a TAFKAL80ETC concert, 0, 50 -Backstage passes to a TAFKAL80ETC concert, -5, 0 -Conjured Mana Cake, -7, 0 - --------- day 11 -------- -name, sellIn, quality -+5 Dexterity Vest, -1, 8 -Aged Brie, -9, 20 -Elixir of the Mongoose, -6, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 4, 38 -Backstage passes to a TAFKAL80ETC concert, -1, 0 -Backstage passes to a TAFKAL80ETC concert, -6, 0 -Conjured Mana Cake, -8, 0 - --------- day 12 -------- -name, sellIn, quality -+5 Dexterity Vest, -2, 6 -Aged Brie, -10, 22 -Elixir of the Mongoose, -7, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 3, 41 -Backstage passes to a TAFKAL80ETC concert, -2, 0 -Backstage passes to a TAFKAL80ETC concert, -7, 0 -Conjured Mana Cake, -9, 0 - --------- day 13 -------- -name, sellIn, quality -+5 Dexterity Vest, -3, 4 -Aged Brie, -11, 24 -Elixir of the Mongoose, -8, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 2, 44 -Backstage passes to a TAFKAL80ETC concert, -3, 0 -Backstage passes to a TAFKAL80ETC concert, -8, 0 -Conjured Mana Cake, -10, 0 - --------- day 14 -------- -name, sellIn, quality -+5 Dexterity Vest, -4, 2 -Aged Brie, -12, 26 -Elixir of the Mongoose, -9, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 1, 47 -Backstage passes to a TAFKAL80ETC concert, -4, 0 -Backstage passes to a TAFKAL80ETC concert, -9, 0 -Conjured Mana Cake, -11, 0 - --------- day 15 -------- -name, sellIn, quality -+5 Dexterity Vest, -5, 0 -Aged Brie, -13, 28 -Elixir of the Mongoose, -10, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, 0, 50 -Backstage passes to a TAFKAL80ETC concert, -5, 0 -Backstage passes to a TAFKAL80ETC concert, -10, 0 -Conjured Mana Cake, -12, 0 - --------- day 16 -------- -name, sellIn, quality -+5 Dexterity Vest, -6, 0 -Aged Brie, -14, 30 -Elixir of the Mongoose, -11, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -1, 0 -Backstage passes to a TAFKAL80ETC concert, -6, 0 -Backstage passes to a TAFKAL80ETC concert, -11, 0 -Conjured Mana Cake, -13, 0 - --------- day 17 -------- -name, sellIn, quality -+5 Dexterity Vest, -7, 0 -Aged Brie, -15, 32 -Elixir of the Mongoose, -12, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -2, 0 -Backstage passes to a TAFKAL80ETC concert, -7, 0 -Backstage passes to a TAFKAL80ETC concert, -12, 0 -Conjured Mana Cake, -14, 0 - --------- day 18 -------- -name, sellIn, quality -+5 Dexterity Vest, -8, 0 -Aged Brie, -16, 34 -Elixir of the Mongoose, -13, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -3, 0 -Backstage passes to a TAFKAL80ETC concert, -8, 0 -Backstage passes to a TAFKAL80ETC concert, -13, 0 -Conjured Mana Cake, -15, 0 - --------- day 19 -------- -name, sellIn, quality -+5 Dexterity Vest, -9, 0 -Aged Brie, -17, 36 -Elixir of the Mongoose, -14, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -4, 0 -Backstage passes to a TAFKAL80ETC concert, -9, 0 -Backstage passes to a TAFKAL80ETC concert, -14, 0 -Conjured Mana Cake, -16, 0 - --------- day 20 -------- -name, sellIn, quality -+5 Dexterity Vest, -10, 0 -Aged Brie, -18, 38 -Elixir of the Mongoose, -15, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -5, 0 -Backstage passes to a TAFKAL80ETC concert, -10, 0 -Backstage passes to a TAFKAL80ETC concert, -15, 0 -Conjured Mana Cake, -17, 0 - --------- day 21 -------- -name, sellIn, quality -+5 Dexterity Vest, -11, 0 -Aged Brie, -19, 40 -Elixir of the Mongoose, -16, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -6, 0 -Backstage passes to a TAFKAL80ETC concert, -11, 0 -Backstage passes to a TAFKAL80ETC concert, -16, 0 -Conjured Mana Cake, -18, 0 - --------- day 22 -------- -name, sellIn, quality -+5 Dexterity Vest, -12, 0 -Aged Brie, -20, 42 -Elixir of the Mongoose, -17, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -7, 0 -Backstage passes to a TAFKAL80ETC concert, -12, 0 -Backstage passes to a TAFKAL80ETC concert, -17, 0 -Conjured Mana Cake, -19, 0 - --------- day 23 -------- -name, sellIn, quality -+5 Dexterity Vest, -13, 0 -Aged Brie, -21, 44 -Elixir of the Mongoose, -18, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -8, 0 -Backstage passes to a TAFKAL80ETC concert, -13, 0 -Backstage passes to a TAFKAL80ETC concert, -18, 0 -Conjured Mana Cake, -20, 0 - --------- day 24 -------- -name, sellIn, quality -+5 Dexterity Vest, -14, 0 -Aged Brie, -22, 46 -Elixir of the Mongoose, -19, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -9, 0 -Backstage passes to a TAFKAL80ETC concert, -14, 0 -Backstage passes to a TAFKAL80ETC concert, -19, 0 -Conjured Mana Cake, -21, 0 - --------- day 25 -------- -name, sellIn, quality -+5 Dexterity Vest, -15, 0 -Aged Brie, -23, 48 -Elixir of the Mongoose, -20, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -10, 0 -Backstage passes to a TAFKAL80ETC concert, -15, 0 -Backstage passes to a TAFKAL80ETC concert, -20, 0 -Conjured Mana Cake, -22, 0 - --------- day 26 -------- -name, sellIn, quality -+5 Dexterity Vest, -16, 0 -Aged Brie, -24, 50 -Elixir of the Mongoose, -21, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -11, 0 -Backstage passes to a TAFKAL80ETC concert, -16, 0 -Backstage passes to a TAFKAL80ETC concert, -21, 0 -Conjured Mana Cake, -23, 0 - --------- day 27 -------- -name, sellIn, quality -+5 Dexterity Vest, -17, 0 -Aged Brie, -25, 50 -Elixir of the Mongoose, -22, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -12, 0 -Backstage passes to a TAFKAL80ETC concert, -17, 0 -Backstage passes to a TAFKAL80ETC concert, -22, 0 -Conjured Mana Cake, -24, 0 - --------- day 28 -------- -name, sellIn, quality -+5 Dexterity Vest, -18, 0 -Aged Brie, -26, 50 -Elixir of the Mongoose, -23, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -13, 0 -Backstage passes to a TAFKAL80ETC concert, -18, 0 -Backstage passes to a TAFKAL80ETC concert, -23, 0 -Conjured Mana Cake, -25, 0 - --------- day 29 -------- -name, sellIn, quality -+5 Dexterity Vest, -19, 0 -Aged Brie, -27, 50 -Elixir of the Mongoose, -24, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -14, 0 -Backstage passes to a TAFKAL80ETC concert, -19, 0 -Backstage passes to a TAFKAL80ETC concert, -24, 0 -Conjured Mana Cake, -26, 0 - --------- day 30 -------- -name, sellIn, quality -+5 Dexterity Vest, -20, 0 -Aged Brie, -28, 50 -Elixir of the Mongoose, -25, 0 -Sulfuras, Hand of Ragnaros, 0, 80 -Sulfuras, Hand of Ragnaros, -1, 80 -Backstage passes to a TAFKAL80ETC concert, -15, 0 -Backstage passes to a TAFKAL80ETC concert, -20, 0 -Backstage passes to a TAFKAL80ETC concert, -25, 0 -Conjured Mana Cake, -27, 0 - From 45733a51292d5a903eb88d50d2c845c63e054636 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Mon, 13 Mar 2017 21:28:39 -0400 Subject: [PATCH 21/22] Removed troublesome folder --- c-check/.gitignore | 10 ---- c-check/GildedRose.c | 90 ----------------------------------- c-check/GildedRose.h | 9 ---- c-check/GildedRoseTextTests.c | 43 ----------------- c-check/Makefile | 50 ------------------- c-check/README.md | 41 ---------------- c-check/test_main.c | 31 ------------ c-check/test_rose.c | 34 ------------- 8 files changed, 308 deletions(-) delete mode 100644 c-check/.gitignore delete mode 100644 c-check/GildedRose.c delete mode 100644 c-check/GildedRose.h delete mode 100644 c-check/GildedRoseTextTests.c delete mode 100644 c-check/Makefile delete mode 100644 c-check/README.md delete mode 100644 c-check/test_main.c delete mode 100644 c-check/test_rose.c diff --git a/c-check/.gitignore b/c-check/.gitignore deleted file mode 100644 index 65962297..00000000 --- a/c-check/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -*.o -*.gch -*.config -*.creator -*.creator.user -*.files -*.includes -*.iml -test_gildedrose -golden_rose diff --git a/c-check/GildedRose.c b/c-check/GildedRose.c deleted file mode 100644 index afb97bbe..00000000 --- a/c-check/GildedRose.c +++ /dev/null @@ -1,90 +0,0 @@ -#include -#include "GildedRose.h" - -Item* -init_item(Item* item, const char *name, int sellIn, int quality) -{ - item->sellIn = sellIn; - item->quality = quality; - item->name = strdup(name); - - return item; -} - -void update_quality(Item items[], int size) -{ - int i; - - for (i = 0; i < size; i++) - { - if (strcmp(items[i].name, "Aged Brie") && strcmp(items[i].name, "Backstage passes to a TAFKAL80ETC concert")) - { - if (items[i].quality > 0) - { - if (strcmp(items[i].name, "Sulfuras, Hand of Ragnaros")) - { - items[i].quality = items[i].quality - 1; - } - } - } - else - { - if (items[i].quality < 50) - { - items[i].quality = items[i].quality + 1; - - if (!strcmp(items[i].name, "Backstage passes to a TAFKAL80ETC concert")) - { - if (items[i].sellIn < 11) - { - if (items[i].quality < 50) - { - items[i].quality = items[i].quality + 1; - } - } - - if (items[i].sellIn < 6) - { - if (items[i].quality < 50) - { - items[i].quality = items[i].quality + 1; - } - } - } - } - } - - if (strcmp(items[i].name, "Sulfuras, Hand of Ragnaros")) - { - items[i].sellIn = items[i].sellIn - 1; - } - - if (items[i].sellIn < 0) - { - if (strcmp(items[i].name, "Aged Brie")) - { - if (strcmp(items[i].name, "Backstage passes to a TAFKAL80ETC concert")) - { - if (items[i].quality > 0) - { - if (strcmp(items[i].name, "Sulfuras, Hand of Ragnaros")) - { - items[i].quality = items[i].quality - 1; - } - } - } - else - { - items[i].quality = items[i].quality - items[i].quality; - } - } - else - { - if (items[i].quality < 50) - { - items[i].quality = items[i].quality + 1; - } - } - } - } -} diff --git a/c-check/GildedRose.h b/c-check/GildedRose.h deleted file mode 100644 index 78d54a08..00000000 --- a/c-check/GildedRose.h +++ /dev/null @@ -1,9 +0,0 @@ -typedef struct -{ - char *name; - int sellIn; - int quality; -} Item; - -extern Item* init_item(Item* item, const char *name, int sellIn, int quality); -extern void update_quality(Item items[], int size); diff --git a/c-check/GildedRoseTextTests.c b/c-check/GildedRoseTextTests.c deleted file mode 100644 index d200ca0c..00000000 --- a/c-check/GildedRoseTextTests.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include "GildedRose.h" - -int -print_item(Item *item) -{ - return printf("%s, %d, %d\n", item->name, item->sellIn, item->quality); -} - -int main() -{ - Item items[9]; - int last = 0; - int day; - int index; - - init_item(items + last++, "+5 Dexterity Vest", 10, 20); - init_item(items + last++, "Aged Brie", 2, 0); - init_item(items + last++, "Elixir of the Mongoose", 5, 7); - init_item(items + last++, "Sulfuras, Hand of Ragnaros", 0, 80); - init_item(items + last++, "Sulfuras, Hand of Ragnaros", -1, 80); - init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 15, 20); - init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 10, 49); - init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 5, 49); - // this Conjured item doesn't yet work properly - init_item(items + last++, "Conjured Mana Cake", 3, 6); - - puts("OMGHAI!"); - - for (day = 0; day <= 30; day++) - { - printf("-------- day %d --------\n", day); - printf("name, sellIn, quality\n"); - for(index = 0; index < last; index++) { - print_item(items + index); - } - - printf("\n"); - - update_quality(items, last); - } - return 0; -} diff --git a/c-check/Makefile b/c-check/Makefile deleted file mode 100644 index dabcf6b1..00000000 --- a/c-check/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -# Makefile for building the kata file with the Google Testing Framework -# -# SYNOPSIS: -# -# make [all] - makes everything, runs tests -# make TARGET - makes the given target. -# make clean - removes all files generated by make. -# make memtest - run memory leak analysis - -# The _POSIX_C_SOURCE definition prevents the compiler from throwing warnings -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 = $(wildcard test_*.c) -TEST_BASE = $(basename ${TEST_SRC}) -TEST_OBJECTS = $(addsuffix .o, ${TEST_BASE}) - -# All files that should be part of your main program should start with 'gilded_' -PROG_SRC = $(wildcard gilded_*.c) -PROG_BASE = $(basename ${PROG_SRC}) -PROG_OBJECTS = $(addsuffix .o, ${PROG_BASE}) - -OBJECT_UNDER_TEST = GildedRose.o ${PROG_OBJECTS} - -# This is the test application. You can run this program to see your test output -TEST_APP = test_gildedrose - - -# This will generate output for several products over a course of several days. -# You can run this application to build golden rule tests -GOLDEN_APP = golden_rose - -all: ${TEST_APP} ${GOLDEN_APP} - ./${TEST_APP} - -${TEST_APP}: ${TEST_OBJECTS} ${OBJECT_UNDER_TEST} - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) - -${GOLDEN_APP}: GildedRoseTextTests.o ${OBJECT_UNDER_TEST} - $(CC) $(CFLAGS) -o $@ $^ - -# If you're not on a mac, you should run memtest (in fact, consider adding it to the 'all' target). -# If you're on a mac, complain to apple for breaking an important development tool. -memtest: ${TEST_APP} - valgrind --leak-check=full --error-exitcode=1 ./${TEST_APP} --nofork - -clean: - rm -f *.o - rm -f ${TEST_APP} diff --git a/c-check/README.md b/c-check/README.md deleted file mode 100644 index ec2cd02e..00000000 --- a/c-check/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# Gilded Rose, C99 Edition - -The command "make" will build and run your tests, as well as build the program -golden_rose, which can serve as the basis for a golden-rule test. - - -## Assumptions - - gnu make and a C compiler (like gcc) is installed on your system and is in the PATH - - The check unit testing library is installed on your system (https://libcheck.github.io/check/) - - pkg-config is installed on your system - -## Usage - - Run `make` to build the program and run all tests - - Files which contain tests should be named `test_*.c` They will automatically - be included in your test suite. - - `GildedRose.h` should not be modified. The Goblin threat is real. - - New program logic may be included in files named `gilded_*.c` which will - automatically be included in both your tests and the final program. - -## Golden Rule tests - - The program `golden_rose` will generate text output. If you capture this - output after your first `make` you can use this as a reference for a golden - rule test. - - You can test your work against this reference by directing the output of your - current golden_rose to a file and using the `diff` utility to compare that - to the reference file you created above. - - To avoid the Goblin threat you can use `git diff GildedRose.h`, which should - have no output if you have left the precious Item structure unchanged. - -## Notes - - This project is tweaked to run on Linux systems, and will mostly work on Macs. - With some changes to the Makefile it can be made to run on BSD systems with - BSD make. An adventurous person could also get it to run on Windows. - - If you are working on a Macintosh computer you cannot run the memtest target, - because valgrind and OS X don't play nice any more. If you want to use the - memory checker OS X does run docker as a first class citizen. - - If you don't have pkg-config on your system, the only changes you'll need to - make are for the requirements of the check library. Mostly you need to - set the appropriate flags for threaded binaries, which may include some - special linker flags. The libcheck documentation will cover what you need - if you want to undertake this change. diff --git a/c-check/test_main.c b/c-check/test_main.c deleted file mode 100644 index 0d5a0de0..00000000 --- a/c-check/test_main.c +++ /dev/null @@ -1,31 +0,0 @@ -#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 deleted file mode 100644 index 30cc7544..00000000 --- a/c-check/test_rose.c +++ /dev/null @@ -1,34 +0,0 @@ -#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; -} From a8561778e964503223816ed1f9eb81d7bee69d73 Mon Sep 17 00:00:00 2001 From: Clay Dowling Date: Mon, 13 Mar 2017 21:30:37 -0400 Subject: [PATCH 22/22] Added C99 Solution --- c99/GildedRose.c | 90 +++++++++++++++++++++++++++++++++++++++ c99/GildedRose.h | 9 ++++ c99/GildedRoseTextTests.c | 43 +++++++++++++++++++ c99/Makefile | 51 ++++++++++++++++++++++ c99/README.md | 41 ++++++++++++++++++ c99/test_main.c | 31 ++++++++++++++ c99/test_rose.c | 34 +++++++++++++++ 7 files changed, 299 insertions(+) create mode 100644 c99/GildedRose.c create mode 100644 c99/GildedRose.h create mode 100644 c99/GildedRoseTextTests.c create mode 100644 c99/Makefile create mode 100644 c99/README.md create mode 100644 c99/test_main.c create mode 100644 c99/test_rose.c diff --git a/c99/GildedRose.c b/c99/GildedRose.c new file mode 100644 index 00000000..afb97bbe --- /dev/null +++ b/c99/GildedRose.c @@ -0,0 +1,90 @@ +#include +#include "GildedRose.h" + +Item* +init_item(Item* item, const char *name, int sellIn, int quality) +{ + item->sellIn = sellIn; + item->quality = quality; + item->name = strdup(name); + + return item; +} + +void update_quality(Item items[], int size) +{ + int i; + + for (i = 0; i < size; i++) + { + if (strcmp(items[i].name, "Aged Brie") && strcmp(items[i].name, "Backstage passes to a TAFKAL80ETC concert")) + { + if (items[i].quality > 0) + { + if (strcmp(items[i].name, "Sulfuras, Hand of Ragnaros")) + { + items[i].quality = items[i].quality - 1; + } + } + } + else + { + if (items[i].quality < 50) + { + items[i].quality = items[i].quality + 1; + + if (!strcmp(items[i].name, "Backstage passes to a TAFKAL80ETC concert")) + { + if (items[i].sellIn < 11) + { + if (items[i].quality < 50) + { + items[i].quality = items[i].quality + 1; + } + } + + if (items[i].sellIn < 6) + { + if (items[i].quality < 50) + { + items[i].quality = items[i].quality + 1; + } + } + } + } + } + + if (strcmp(items[i].name, "Sulfuras, Hand of Ragnaros")) + { + items[i].sellIn = items[i].sellIn - 1; + } + + if (items[i].sellIn < 0) + { + if (strcmp(items[i].name, "Aged Brie")) + { + if (strcmp(items[i].name, "Backstage passes to a TAFKAL80ETC concert")) + { + if (items[i].quality > 0) + { + if (strcmp(items[i].name, "Sulfuras, Hand of Ragnaros")) + { + items[i].quality = items[i].quality - 1; + } + } + } + else + { + items[i].quality = items[i].quality - items[i].quality; + } + } + else + { + if (items[i].quality < 50) + { + items[i].quality = items[i].quality + 1; + } + } + } + } +} diff --git a/c99/GildedRose.h b/c99/GildedRose.h new file mode 100644 index 00000000..78d54a08 --- /dev/null +++ b/c99/GildedRose.h @@ -0,0 +1,9 @@ +typedef struct +{ + char *name; + int sellIn; + int quality; +} Item; + +extern Item* init_item(Item* item, const char *name, int sellIn, int quality); +extern void update_quality(Item items[], int size); diff --git a/c99/GildedRoseTextTests.c b/c99/GildedRoseTextTests.c new file mode 100644 index 00000000..d200ca0c --- /dev/null +++ b/c99/GildedRoseTextTests.c @@ -0,0 +1,43 @@ +#include +#include "GildedRose.h" + +int +print_item(Item *item) +{ + return printf("%s, %d, %d\n", item->name, item->sellIn, item->quality); +} + +int main() +{ + Item items[9]; + int last = 0; + int day; + int index; + + init_item(items + last++, "+5 Dexterity Vest", 10, 20); + init_item(items + last++, "Aged Brie", 2, 0); + init_item(items + last++, "Elixir of the Mongoose", 5, 7); + init_item(items + last++, "Sulfuras, Hand of Ragnaros", 0, 80); + init_item(items + last++, "Sulfuras, Hand of Ragnaros", -1, 80); + init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 15, 20); + init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 10, 49); + init_item(items + last++, "Backstage passes to a TAFKAL80ETC concert", 5, 49); + // this Conjured item doesn't yet work properly + init_item(items + last++, "Conjured Mana Cake", 3, 6); + + puts("OMGHAI!"); + + for (day = 0; day <= 30; day++) + { + printf("-------- day %d --------\n", day); + printf("name, sellIn, quality\n"); + for(index = 0; index < last; index++) { + print_item(items + index); + } + + printf("\n"); + + update_quality(items, last); + } + return 0; +} diff --git a/c99/Makefile b/c99/Makefile new file mode 100644 index 00000000..113d1552 --- /dev/null +++ b/c99/Makefile @@ -0,0 +1,51 @@ +# Makefile for building the kata file with the Google Testing Framework +# +# SYNOPSIS: +# +# make [all] - makes everything, runs tests +# make TARGET - makes the given target. +# make clean - removes all files generated by make. +# make memtest - run memory leak analysis + +# The _POSIX_C_SOURCE definition prevents the compiler from throwing warnings +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 = $(wildcard test_*.c) +TEST_BASE = $(basename ${TEST_SRC}) +TEST_OBJECTS = $(addsuffix .o, ${TEST_BASE}) + +# All files that should be part of your main program should start with 'gilded_' +PROG_SRC = $(wildcard gilded_*.c) +PROG_BASE = $(basename ${PROG_SRC}) +PROG_OBJECTS = $(addsuffix .o, ${PROG_BASE}) + +OBJECT_UNDER_TEST = GildedRose.o ${PROG_OBJECTS} + +# This is the test application. You can run this program to see your test output +TEST_APP = test_gildedrose + + +# This will generate output for several products over a course of several days. +# You can run this application to build golden rule tests +GOLDEN_APP = golden_rose + +all: ${TEST_APP} ${GOLDEN_APP} + ./${TEST_APP} + +${TEST_APP}: ${TEST_OBJECTS} ${OBJECT_UNDER_TEST} + $(CC) $(CFLAGS) -o $@ $^ $(LIBS) + +${GOLDEN_APP}: GildedRoseTextTests.o ${OBJECT_UNDER_TEST} + $(CC) $(CFLAGS) -o $@ $^ + +# If you're not on a mac, you should run memtest (in fact, consider adding it to the 'all' target). +# If you're on a mac, complain to apple for breaking an important development tool. +memtest: ${TEST_APP} + valgrind --leak-check=full --error-exitcode=1 ./${TEST_APP} --nofork + +clean: + rm -f *.o + rm -f ${TEST_APP} + rm -f ${GOLDEN_APP} diff --git a/c99/README.md b/c99/README.md new file mode 100644 index 00000000..ec2cd02e --- /dev/null +++ b/c99/README.md @@ -0,0 +1,41 @@ +# Gilded Rose, C99 Edition + +The command "make" will build and run your tests, as well as build the program +golden_rose, which can serve as the basis for a golden-rule test. + + +## Assumptions + - gnu make and a C compiler (like gcc) is installed on your system and is in the PATH + - The check unit testing library is installed on your system (https://libcheck.github.io/check/) + - pkg-config is installed on your system + +## Usage + - Run `make` to build the program and run all tests + - Files which contain tests should be named `test_*.c` They will automatically + be included in your test suite. + - `GildedRose.h` should not be modified. The Goblin threat is real. + - New program logic may be included in files named `gilded_*.c` which will + automatically be included in both your tests and the final program. + +## Golden Rule tests + - The program `golden_rose` will generate text output. If you capture this + output after your first `make` you can use this as a reference for a golden + rule test. + - You can test your work against this reference by directing the output of your + current golden_rose to a file and using the `diff` utility to compare that + to the reference file you created above. + - To avoid the Goblin threat you can use `git diff GildedRose.h`, which should + have no output if you have left the precious Item structure unchanged. + +## Notes + - This project is tweaked to run on Linux systems, and will mostly work on Macs. + With some changes to the Makefile it can be made to run on BSD systems with + BSD make. An adventurous person could also get it to run on Windows. + - If you are working on a Macintosh computer you cannot run the memtest target, + because valgrind and OS X don't play nice any more. If you want to use the + memory checker OS X does run docker as a first class citizen. + - If you don't have pkg-config on your system, the only changes you'll need to + make are for the requirements of the check library. Mostly you need to + set the appropriate flags for threaded binaries, which may include some + special linker flags. The libcheck documentation will cover what you need + if you want to undertake this change. diff --git a/c99/test_main.c b/c99/test_main.c new file mode 100644 index 00000000..0d5a0de0 --- /dev/null +++ b/c99/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/c99/test_rose.c b/c99/test_rose.c new file mode 100644 index 00000000..30cc7544 --- /dev/null +++ b/c99/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; +}