From 8086d576e47a883915ef48c8b0879462eca79557 Mon Sep 17 00:00:00 2001 From: Gregory Date: Mon, 8 Oct 2018 02:39:31 +0300 Subject: [PATCH] added munit tests --- .gitignore | 1 + .gitmodules | 3 +++ Makefile | 33 +++++++++++++++++++++------------ lib/munit | 1 + t/test_test.c | 8 ++++++++ 5 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 .gitmodules create mode 160000 lib/munit create mode 100644 t/test_test.c diff --git a/.gitignore b/.gitignore index 6ff8d351..1493ffef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ ft_ssl +ft_ssl_test *.o *.a diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..ee5bd140 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/munit"] + path = lib/munit + url = git@github.com:nemequ/munit.git diff --git a/Makefile b/Makefile index 795632e5..a44a575b 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,9 @@ LIBFT_INC := -I $(LIBFT_DIR)includes/ LIBFT_LIB := -lft -L $(LIBFT_DIR) LIBFT = $(LIBFT_DIR)libft.a +MUINUT_DIR := $(LIB_DIR)munit/ +MUINUT_INC := -I $(MUINUT_DIR) + # project source files SRC = main.c @@ -42,6 +45,13 @@ OBJ = $(addprefix $(OBJ_DIR), $(SRC:.c=.o)) # project test files +TEST_BIN = ft_ssl_test + +TEST_SRC = test_test.c + +TEST_SRC += munit.c + +TEST_OBJ = $(addprefix $(OBJ_DIR), $(TEST_SRC:.c=.o)) # compilation flags @@ -73,7 +83,7 @@ LINK_FLAGS = "" # header flags -HEADER_FLAGS = "" +HEADER_FLAGS = $(MUINUT_INC) # compiler @@ -83,15 +93,16 @@ CC := clang all: $(NAME) -$(NAME): $(LIBFT) $(OBJ) +$(NAME): check $(LIBFT) $(OBJ) $(CC) $(OBJ) $(LINK_FLAGS) -o $(NAME) -$(TEST_NAME): $(LIBFT) $(TEST_OBJ) - $(CC) $(TEST_OBJ) $(LINK_FLAGS) -o $(TEST_NAME) +check: $(TEST_BIN) + ./$(TEST_BIN) -$(OBJ): | $(OBJ_DIR) +$(TEST_BIN): $(LIBFT) $(TEST_OBJ) + $(CC) $(TEST_OBJ) $(LINK_FLAGS) -o $(TEST_BIN) -$(TEST_OBJ): | $(OBJ_DIR) +$(TEST_OBJ) $(OBJ): | $(OBJ_DIR) $(OBJ_DIR): mkdir $(OBJ_DIR) @@ -102,10 +113,6 @@ $(OBJ_DIR)%.o: %.c $(LIBFT): $(MAKE) -C $(LIBFT_DIR) -check: $(TEST_NAME) - clear - ./$(TEST_NAME) - clean: rm -f $(OBJ) rm -f $(TEST_OBJ) @@ -113,7 +120,6 @@ clean: fclean: clean rm -f $(NAME) - rm -f $(TEST_NAME) rm -rf $(OBJ_DIR) $(MAKE) -C $(LIBFT_DIR) fclean @@ -126,6 +132,9 @@ multi: # special stuff -vpath %.c $(SRC_DIR) +vpath %.c $(SRC_DIR) \ + $(TST_DIR) \ + $(MUINUT_DIR) + .PHONY: all check clean fclean re multi diff --git a/lib/munit b/lib/munit new file mode 160000 index 00000000..439de4a9 --- /dev/null +++ b/lib/munit @@ -0,0 +1 @@ +Subproject commit 439de4a9b136bc3b5163e73d4caf37c590bef875 diff --git a/t/test_test.c b/t/test_test.c new file mode 100644 index 00000000..a774dcee --- /dev/null +++ b/t/test_test.c @@ -0,0 +1,8 @@ +#define MUNIT_ENABLE_ASSERT_ALIASES +#include "munit.h" + +int main(int argc, char** argv) { + (void)argc; + (void)argv; + assert_int(argc, ==, 1); +}