From 9db52bc5ef545a3fa9973002e9a28a2ece68d029 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 31 Jan 2020 08:08:59 +0100 Subject: Setup unit test with unity --- test/Makefile | 48 ++++++++++++++++++++++++++++++++ test/include/libft_test.h | 8 ++++++ test/libft_test | Bin 0 -> 34012 bytes test/src/runner/test_ft_strlen_runner.c | 6 ++++ test/src/str/test_ft_strlen.c | 14 ++++++++++ 5 files changed, 76 insertions(+) create mode 100644 test/Makefile create mode 100644 test/include/libft_test.h create mode 100755 test/libft_test create mode 100644 test/src/runner/test_ft_strlen_runner.c create mode 100644 test/src/str/test_ft_strlen.c (limited to 'test') diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..4d84321 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,48 @@ +MAKE = make +MAKE_ARGS = --no-print-directory + +UNITY_DIR = ../vendor/_unity +LIBFT_DIR = .. + +SRC_DIR = src +INCLUDE_DIR = include + +CC = gcc +CCFLAGS = -I$(INCLUDE_DIR) -I$(UNITY_DIR)/include -I$(LIBFT_DIR)/include -Wall -Wextra -Werror +LDFLAGS = -L$(UNITY_DIR) -lunity -L$(LIBFT_DIR) -lft + +NAME = libft_test + +SRC = $(shell find $(SRC_DIR) -type f -name "*.c") +OBJ = $(SRC:.c=.o) + + +all: unity_all $(NAME) + +run: all + @echo "Test: Running" + @./$(NAME) + +$(NAME): $(OBJ) + @echo "Test: Linking: $@" + @$(CC) -o $@ $^ $(LDFLAGS) + +%.o: %.c + @echo "Test: Compiling: $@" + @$(CC) $(CCFLAGS) -c -o $@ $< + +clean: unity_fclean + @echo "Test: Removing object" + @$(RM) $(OBJ) + +fclean: + @echo "Test: Removing executable" + @$(RM) $(NAME) + +re: fclean all + +unity_all: + @$(MAKE) $(MAKE_ARGS) -s -C $(UNITY_DIR) all + +unity_fclean: + @$(MAKE) $(MAKE_ARGS) -s -C $(UNITY_DIR) fclean diff --git a/test/include/libft_test.h b/test/include/libft_test.h new file mode 100644 index 0000000..1c5ebb5 --- /dev/null +++ b/test/include/libft_test.h @@ -0,0 +1,8 @@ +#ifndef LIBFT_TEST_H +# define LIBFT_TEST_H + +# include "unity.h" +# include "unity_fixture.h" +# include "libft.h" + +#endif diff --git a/test/libft_test b/test/libft_test new file mode 100755 index 0000000..13cbab2 Binary files /dev/null and b/test/libft_test differ diff --git a/test/src/runner/test_ft_strlen_runner.c b/test/src/runner/test_ft_strlen_runner.c new file mode 100644 index 0000000..368c033 --- /dev/null +++ b/test/src/runner/test_ft_strlen_runner.c @@ -0,0 +1,6 @@ +#include "libft_test.h" + +TEST_GROUP_RUNNER(ft_strlen) +{ + RUN_TEST_CASE(ft_strlen, yo); +} diff --git a/test/src/str/test_ft_strlen.c b/test/src/str/test_ft_strlen.c new file mode 100644 index 0000000..1e4e1c4 --- /dev/null +++ b/test/src/str/test_ft_strlen.c @@ -0,0 +1,14 @@ +#include "libft_test.h" + +TEST_GROUP(ft_strlen); + +TEST_SETUP(ft_strlen) +{} + +TEST_TEAR_DOWN(ft_strlen) +{} + +TEST(ft_strlen, yo) +{ + TEST_ASSERT_EQUAL(0, 0); +} -- cgit