From 08a0bf6d358b33fb77f0bfb095863336e1f6ef74 Mon Sep 17 00:00:00 2001 From: Matt Decker Date: Sun, 26 Jun 2022 08:53:07 -0500 Subject: [PATCH] Delete C directory --- C/GildedRose.c | 98 ---------------------------------------- C/GildedRose.h | 15 ------ C/GildedRoseTextTests.c | 43 ------------------ C/GildedRoseUnitTests.cc | 43 ------------------ C/Makefile | 51 --------------------- C/README.txt | 5 -- C/run-once.sh | 2 - 7 files changed, 257 deletions(-) delete mode 100644 C/GildedRose.c delete mode 100644 C/GildedRose.h delete mode 100644 C/GildedRoseTextTests.c delete mode 100644 C/GildedRoseUnitTests.cc delete mode 100644 C/Makefile delete mode 100644 C/README.txt delete mode 100755 C/run-once.sh diff --git a/C/GildedRose.c b/C/GildedRose.c deleted file mode 100644 index 5c86edc3..00000000 --- a/C/GildedRose.c +++ /dev/null @@ -1,98 +0,0 @@ -#include -#include "GildedRose.h" -#include - -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; - } - } - } - } -} diff --git a/C/GildedRose.h b/C/GildedRose.h deleted file mode 100644 index 9883d7a9..00000000 --- a/C/GildedRose.h +++ /dev/null @@ -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 \ No newline at end of file diff --git a/C/GildedRoseTextTests.c b/C/GildedRoseTextTests.c deleted file mode 100644 index d200ca0c..00000000 --- a/C/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/GildedRoseUnitTests.cc b/C/GildedRoseUnitTests.cc deleted file mode 100644 index ff7dec86..00000000 --- a/C/GildedRoseUnitTests.cc +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include - -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); -} diff --git a/C/Makefile b/C/Makefile deleted file mode 100644 index 3a695892..00000000 --- a/C/Makefile +++ /dev/null @@ -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} diff --git a/C/README.txt b/C/README.txt deleted file mode 100644 index 2bc1f69b..00000000 --- a/C/README.txt +++ /dev/null @@ -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 diff --git a/C/run-once.sh b/C/run-once.sh deleted file mode 100755 index 4f6b2303..00000000 --- a/C/run-once.sh +++ /dev/null @@ -1,2 +0,0 @@ -make -./GildedRoseTextTests