lib

morphux C utility library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/lib

commit edfedc482750d0430e0be89ef8fef0b1e82159d8
parent 0b2c33fbb46ab05108f7dd0fb704204cb70bc36b
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Mon, 24 Apr 2017 19:13:31 +0200

Add(Tests): Add test for m_debug function

Diffstat:
MMakefile | 2+-
Mtests/Makefile | 2+-
Mtests/test_print.c | 16++++++++++++++++
3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile @@ -35,7 +35,7 @@ $(NAME): $(OBJS) $(LIB) $(LFLAGS) $(NAME) $(OBJS) check: all - $(MAKE) fclean all CFLAGS="$(CFLAGS) -Wno-error -DCOMPILE_WITH_TEST" + $(MAKE) fclean all CFLAGS="$(CFLAGS) -Wno-error -DCOMPILE_WITH_TEST -DDEBUG" make -C tests re check doc: diff --git a/tests/Makefile b/tests/Makefile @@ -1,6 +1,6 @@ NAME = test CC = gcc -CFLAGS = -Wall -Wextra -Wno-unused-result -g -O3 -I../inc +CFLAGS = -Wall -Wextra -Wno-unused-result -g -O3 -I../inc -DDEBUG LDFLAGS = -lmorphux SRCS = $(wildcard *.c) OBJS = $(SRCS:%.c=%.o) diff --git a/tests/test_print.c b/tests/test_print.c @@ -60,6 +60,21 @@ TEST(print_panic) { return TEST_SUCCESS; } +TEST(print_debug) { + int st, fd[2]; + pid_t pid; + + pipe(fd); + if ((pid = fork()) == 0) { + DUP_ALL_OUTPUTS(fd); + m_debug("Test"); + exit(0); + } else { + WAIT_AND_CLOSE(pid, st, fd); + } + return TEST_SUCCESS; +} + TEST(print_log_err) { TEST_ASSERT(m_log("Balec/20") == false, "Return is wrong"); return TEST_SUCCESS; @@ -192,6 +207,7 @@ void register_print_tests(void) { reg_test("mprint", print_warning); reg_test("mprint", print_error); reg_test("mprint", print_panic); + reg_test("mprint", print_debug); reg_test("mprint", print_log_err); reg_test("mprint", print_log_init); reg_test("mprint", print_log_1);