tests: add testutils

This commit is contained in:
Khaïs COLIN 2025-02-13 15:17:30 +01:00
parent 5b00059526
commit 18a2835a7c
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
3 changed files with 43 additions and 1 deletions

View file

@ -4,7 +4,7 @@ rawtests = \
tests = $(addprefix test_,$(rawtests))
test_objs = $(addsuffix .o,$(tests))
objs := $(addprefix ../,$(objs))
objs := $(addprefix ../,$(objs)) testutil.o
all_objs = $(objs) $(test_objs)
deps = $(all_objs:.o=.d)
LDLIBS = \

24
tests/testutil.c Normal file
View file

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* testutil.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/13 15:21:09 by khais #+# #+# */
/* Updated: 2025/02/13 15:57:00 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <assert.h>
void assert_strequal(char *str1, char *str2)
{
int ret;
ret = ft_strcmp(str1, str2);
if (ret != 0)
ft_dprintf(STDERR_FILENO, "Expected '%s' to eq '%s'\n", str1, str2);
assert(ret == 0);
}

18
tests/testutil.h Normal file
View file

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* testutil.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/13 15:57:21 by khais #+# #+# */
/* Updated: 2025/02/13 15:57:44 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TESTUTIL_H
# define TESTUTIL_H
void assert_strequal(char *str1, char *str2);
#endif