diff options
| -rw-r--r-- | src/02/04/Makefile | 38 | ||||
| -rw-r--r-- | src/02/04/hash.c | 7 | ||||
| -rw-r--r-- | src/02/04/hash.h | 4 | ||||
| -rw-r--r-- | src/02/04/hash_test.c | 26 | ||||
| -rw-r--r-- | src/02/04/main.c | 6 |
5 files changed, 81 insertions, 0 deletions
diff --git a/src/02/04/Makefile b/src/02/04/Makefile new file mode 100644 index 0000000..fff6e95 --- /dev/null +++ b/src/02/04/Makefile @@ -0,0 +1,38 @@ +#!/usr/bin/make -f +SHELL=/bin/sh + +CC=clang +CFLAGS=-std=c99 +TEST_LIBS = -lcgreen + +BUILDDIR := build +OBJS := $(addprefix $(BUILDDIR)/,hash.o) +TEST_OBJS := $(addprefix $(BUILDDIR)/,hash_test.o) + +$(BUILDDIR)/%.o : %.c + $(COMPILE.c) $(OUTPUT_OPTION) $< + +.PHONY: all +all: $(OBJS) $(BUILDDIR)/main.o + $(CC) $(OBJS) $(BUILDDIR)/main.o -o $(BUILDDIR)/program + +.PHONY: test +test: $(OBJS) $(TEST_OBJS) + $(CC) $(OBJS) $(TEST_OBJS) $(TEST_LIBS) -o $(BUILDDIR)/test + +$(OBJS): | $(BUILDDIR) + +$(TEST_OBJS): | $(BUILDDIR) + +$(BUILDDIR): + mkdir $(BUILDDIR) + +.PHONY: clean +clean: + rm -fr build + +run : all + ./build/program + +run_test : test + cgreen-runner -c -v $(BUILDDIR)/test diff --git a/src/02/04/hash.c b/src/02/04/hash.c new file mode 100644 index 0000000..c1a2bf9 --- /dev/null +++ b/src/02/04/hash.c @@ -0,0 +1,7 @@ +#include "hash.h" +#include <stdio.h> + +Hash *hash_init(int size) +{ + return NULL; +} diff --git a/src/02/04/hash.h b/src/02/04/hash.h new file mode 100644 index 0000000..6301584 --- /dev/null +++ b/src/02/04/hash.h @@ -0,0 +1,4 @@ +typedef struct { +} Hash; + +Hash *hash_init(int size); diff --git a/src/02/04/hash_test.c b/src/02/04/hash_test.c new file mode 100644 index 0000000..6eeaebd --- /dev/null +++ b/src/02/04/hash_test.c @@ -0,0 +1,26 @@ +#include "hash.h" +#include <cgreen/cgreen.h> +#include <string.h> + +Describe(HashTable); +BeforeEach(HashTable) {} +AfterEach(HashTable) {} + +Ensure(HashTable, when_initializing_a_hash) { + Hash *hash = hash_init(13); + + assert_that(hash, is_not_equal_to(NULL)); +} + +TestSuite *hash_table_tests() { + TestSuite *suite = create_test_suite(); + + add_test_with_context(suite, HashTable, when_initializing_a_hash); + return suite; +} + +int main(int argc, char **argv) { + TestSuite *suite = create_test_suite(); + add_suite(suite, hash_table_tests()); + return run_test_suite(suite, create_text_reporter()); +} diff --git a/src/02/04/main.c b/src/02/04/main.c new file mode 100644 index 0000000..d2dd2af --- /dev/null +++ b/src/02/04/main.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + return 0; +} |
