mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-17 15:31:27 +00:00
Delete C directory
This commit is contained in:
parent
eceda92a2c
commit
08a0bf6d35
@ -1,98 +0,0 @@
|
|||||||
#include <string.h>
|
|
||||||
#include "GildedRose.h"
|
|
||||||
#include <stdio.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern char*
|
|
||||||
print_item(char* buffer, Item* item)
|
|
||||||
{
|
|
||||||
sprintf(buffer, "%s, %d, %d", item->name, item->sellIn, item->quality);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
#ifndef ROSE_INCLUDED
|
|
||||||
#define ROSE_INCLUDED
|
|
||||||
|
|
||||||
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);
|
|
||||||
extern char* print_item(char* buffer, Item* item);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
#include <CppUTest/TestHarness.h>
|
|
||||||
#include <CppUTest/CommandLineTestRunner.h>
|
|
||||||
#include <CppUTestExt/MockSupport.h>
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include "GildedRose.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_GROUP(TestGildedRoseGroup)
|
|
||||||
{
|
|
||||||
void setup() {
|
|
||||||
}
|
|
||||||
void teardown() {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST(TestGildedRoseGroup, FirstTest)
|
|
||||||
{
|
|
||||||
Item items[1];
|
|
||||||
init_item(items, "Foo", 0, 0);
|
|
||||||
update_quality(items, 1);
|
|
||||||
STRCMP_EQUAL("fixme", items[0].name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void example()
|
|
||||||
{
|
|
||||||
Item items[6];
|
|
||||||
int last = 0;
|
|
||||||
|
|
||||||
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++, "Backstage passes to a TAFKAL80ETC concert", 15, 20);
|
|
||||||
init_item(items + last++, "Conjured Mana Cake", 3, 6);
|
|
||||||
update_quality(items, last);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int ac, char** av)
|
|
||||||
{
|
|
||||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
|
||||||
}
|
|
||||||
51
C/Makefile
51
C/Makefile
@ -1,51 +0,0 @@
|
|||||||
# Makefile for building the kata file with the Google Testing Framework
|
|
||||||
#
|
|
||||||
# SYNOPSIS:
|
|
||||||
#
|
|
||||||
# make [all] - makes everything.
|
|
||||||
# make TARGET - makes the given target.
|
|
||||||
# make clean - removes all files generated by make.
|
|
||||||
|
|
||||||
# Please tweak the following variable definitions as needed by your
|
|
||||||
# project.
|
|
||||||
|
|
||||||
# Points to the root of CppUTest, relative to where this file is.
|
|
||||||
# Remember to tweak this if you move this file.
|
|
||||||
CPPUTEST_HOME = CppUTest
|
|
||||||
|
|
||||||
# Where to find user code.
|
|
||||||
USER_DIR = .
|
|
||||||
|
|
||||||
# Flags passed to the preprocessor.
|
|
||||||
CPPFLAGS += -I$(CPPUTEST_HOME)/include
|
|
||||||
|
|
||||||
# Flags passed to the C++ compiler.
|
|
||||||
CFLAGS += -g -Wall -Wextra
|
|
||||||
|
|
||||||
LD_LIBRARIES = -L$(CPPUTEST_HOME)/lib -lCppUTest
|
|
||||||
|
|
||||||
# All tests produced by this Makefile. Remember to add new tests you
|
|
||||||
# created to the list.
|
|
||||||
TESTS = GildedRoseUnitTests
|
|
||||||
|
|
||||||
TEXTTESTS = GildedRoseTextTests
|
|
||||||
|
|
||||||
# House-keeping build targets.
|
|
||||||
|
|
||||||
all : $(TESTS) $(TEXTTESTS)
|
|
||||||
|
|
||||||
GildedRose.o : $(USER_DIR)/GildedRose.c
|
|
||||||
|
|
||||||
GildedRoseUnitTests : $(USER_DIR)/GildedRoseUnitTests.cc GildedRose.o
|
|
||||||
$(CXX) $(CPPFLAGS) $(CFLAGS) -o $@ $(USER_DIR)/GildedRoseUnitTests.cc GildedRose.o $(LD_LIBRARIES)
|
|
||||||
|
|
||||||
GildedRoseTextTests.o : $(USER_DIR)/GildedRoseTextTests.c
|
|
||||||
|
|
||||||
GildedRoseTextTests : GildedRoseTextTests.o GildedRose.o
|
|
||||||
$(CC) $^ -o $@
|
|
||||||
|
|
||||||
clean :
|
|
||||||
rm -f $(TESTS) $(TEXTTESTS) *.o *~
|
|
||||||
|
|
||||||
check-syntax:
|
|
||||||
gcc $(CPPFLAGS) -o /dev/null -S ${CHK_SOURCES}
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
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
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
make
|
|
||||||
./GildedRoseTextTests
|
|
||||||
Loading…
Reference in New Issue
Block a user