test tests
This commit is contained in:
parent
8086d576e4
commit
ca2852bd3b
7 changed files with 85 additions and 11 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@ ft_ssl
|
|||
ft_ssl_test
|
||||
*.o
|
||||
*.a
|
||||
.vscode
|
||||
|
|
8
Makefile
8
Makefile
|
@ -47,7 +47,8 @@ OBJ = $(addprefix $(OBJ_DIR), $(SRC:.c=.o))
|
|||
|
||||
TEST_BIN = ft_ssl_test
|
||||
|
||||
TEST_SRC = test_test.c
|
||||
TEST_SRC = main_test.c \
|
||||
test_tests.c
|
||||
|
||||
TEST_SRC += munit.c
|
||||
|
||||
|
@ -83,7 +84,8 @@ LINK_FLAGS = ""
|
|||
|
||||
# header flags
|
||||
|
||||
HEADER_FLAGS = $(MUINUT_INC)
|
||||
HEADER_FLAGS = -I $(INC_DIR) \
|
||||
$(MUINUT_INC)
|
||||
|
||||
# compiler
|
||||
|
||||
|
@ -97,6 +99,7 @@ $(NAME): check $(LIBFT) $(OBJ)
|
|||
$(CC) $(OBJ) $(LINK_FLAGS) -o $(NAME)
|
||||
|
||||
check: $(TEST_BIN)
|
||||
clear
|
||||
./$(TEST_BIN)
|
||||
|
||||
$(TEST_BIN): $(LIBFT) $(TEST_OBJ)
|
||||
|
@ -120,7 +123,6 @@ clean:
|
|||
|
||||
fclean: clean
|
||||
rm -f $(NAME)
|
||||
rm -rf $(OBJ_DIR)
|
||||
$(MAKE) -C $(LIBFT_DIR) fclean
|
||||
|
||||
re: fclean all
|
||||
|
|
13
inc/tests.h
Normal file
13
inc/tests.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#ifndef TESTS
|
||||
# define TESTS
|
||||
|
||||
#define MUNIT_ENABLE_ASSERT_ALIASES
|
||||
#include "munit.h"
|
||||
#include "tests_macros.h"
|
||||
|
||||
// test tests
|
||||
CASE(should_pass);
|
||||
CASE(should_skip);
|
||||
CASE(should_fail);
|
||||
|
||||
#endif
|
22
inc/tests_macros.h
Normal file
22
inc/tests_macros.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef TESTS_MACROS
|
||||
# define TESTS_MACROS
|
||||
|
||||
#include "munit.h"
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
#define TEST_RESULT MunitResult
|
||||
#define TEST_PARAMS const MunitParameter test_params[]
|
||||
#define TEST_DATA void *test_data
|
||||
#define CASE(f) TEST_RESULT f(TEST_PARAMS, TEST_DATA)
|
||||
|
||||
#define N(name) (char *)name
|
||||
#define T(test_function) test_function
|
||||
#define S(setup_function) setup_function
|
||||
#define TD(tear_down_function) tear_down_function
|
||||
#define O(options) options
|
||||
#define P(paramenters) paramenters
|
||||
#define IT(n, t, s, td, o, p) { N(n), T(t), S(s), TD(td), O(o), P(p) }
|
||||
#define END_IT IT(NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL)
|
||||
|
||||
#endif
|
21
t/main_test.c
Normal file
21
t/main_test.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include "tests.h"
|
||||
|
||||
MunitTest test_tests[] = {
|
||||
IT("/should_pass", should_pass, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL),
|
||||
IT("/should_fail", should_fail, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL),
|
||||
IT("/should_skip", should_skip, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL),
|
||||
END_IT
|
||||
};
|
||||
|
||||
static const MunitSuite suite = {
|
||||
(char *)"/test_tests_suite", /* name */
|
||||
test_tests, /* tests */
|
||||
NULL, /* suites */
|
||||
1, /* iterations */
|
||||
MUNIT_SUITE_OPTION_NONE /* options */
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
return munit_suite_main(&suite, NULL, argc, argv);
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
#define MUNIT_ENABLE_ASSERT_ALIASES
|
||||
#include "munit.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
assert_int(argc, ==, 1);
|
||||
}
|
23
t/test_tests.c
Normal file
23
t/test_tests.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include "tests.h"
|
||||
|
||||
TEST_RESULT should_pass(TEST_PARAMS, TEST_DATA)
|
||||
{
|
||||
UNUSED(test_params);
|
||||
UNUSED(test_data);
|
||||
return MUNIT_OK;
|
||||
}
|
||||
|
||||
TEST_RESULT should_fail(TEST_PARAMS, TEST_DATA)
|
||||
{
|
||||
UNUSED(test_params);
|
||||
UNUSED(test_data);
|
||||
return MUNIT_SKIP;
|
||||
return MUNIT_FAIL;
|
||||
}
|
||||
|
||||
TEST_RESULT should_skip(TEST_PARAMS, TEST_DATA)
|
||||
{
|
||||
UNUSED(test_params);
|
||||
UNUSED(test_data);
|
||||
return MUNIT_SKIP;
|
||||
}
|
Loading…
Reference in a new issue