added munit tests

This commit is contained in:
Gregory 2018-10-08 02:39:31 +03:00
parent 9cc790d17a
commit 8086d576e4
5 changed files with 34 additions and 12 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
ft_ssl ft_ssl
ft_ssl_test
*.o *.o
*.a *.a

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "lib/munit"]
path = lib/munit
url = git@github.com:nemequ/munit.git

View file

@ -31,6 +31,9 @@ LIBFT_INC := -I $(LIBFT_DIR)includes/
LIBFT_LIB := -lft -L $(LIBFT_DIR) LIBFT_LIB := -lft -L $(LIBFT_DIR)
LIBFT = $(LIBFT_DIR)libft.a LIBFT = $(LIBFT_DIR)libft.a
MUINUT_DIR := $(LIB_DIR)munit/
MUINUT_INC := -I $(MUINUT_DIR)
# project source files # project source files
SRC = main.c SRC = main.c
@ -42,6 +45,13 @@ OBJ = $(addprefix $(OBJ_DIR), $(SRC:.c=.o))
# project test files # 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 # compilation flags
@ -73,7 +83,7 @@ LINK_FLAGS = ""
# header flags # header flags
HEADER_FLAGS = "" HEADER_FLAGS = $(MUINUT_INC)
# compiler # compiler
@ -83,15 +93,16 @@ CC := clang
all: $(NAME) all: $(NAME)
$(NAME): $(LIBFT) $(OBJ) $(NAME): check $(LIBFT) $(OBJ)
$(CC) $(OBJ) $(LINK_FLAGS) -o $(NAME) $(CC) $(OBJ) $(LINK_FLAGS) -o $(NAME)
$(TEST_NAME): $(LIBFT) $(TEST_OBJ) check: $(TEST_BIN)
$(CC) $(TEST_OBJ) $(LINK_FLAGS) -o $(TEST_NAME) ./$(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): $(OBJ_DIR):
mkdir $(OBJ_DIR) mkdir $(OBJ_DIR)
@ -102,10 +113,6 @@ $(OBJ_DIR)%.o: %.c
$(LIBFT): $(LIBFT):
$(MAKE) -C $(LIBFT_DIR) $(MAKE) -C $(LIBFT_DIR)
check: $(TEST_NAME)
clear
./$(TEST_NAME)
clean: clean:
rm -f $(OBJ) rm -f $(OBJ)
rm -f $(TEST_OBJ) rm -f $(TEST_OBJ)
@ -113,7 +120,6 @@ clean:
fclean: clean fclean: clean
rm -f $(NAME) rm -f $(NAME)
rm -f $(TEST_NAME)
rm -rf $(OBJ_DIR) rm -rf $(OBJ_DIR)
$(MAKE) -C $(LIBFT_DIR) fclean $(MAKE) -C $(LIBFT_DIR) fclean
@ -126,6 +132,9 @@ multi:
# special stuff # special stuff
vpath %.c $(SRC_DIR) vpath %.c $(SRC_DIR) \
$(TST_DIR) \
$(MUINUT_DIR)
.PHONY: all check clean fclean re multi .PHONY: all check clean fclean re multi

1
lib/munit Submodule

@ -0,0 +1 @@
Subproject commit 439de4a9b136bc3b5163e73d4caf37c590bef875

8
t/test_test.c Normal file
View file

@ -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);
}