aboutsummaryrefslogtreecommitdiff
path: root/test/ft_strlen_test.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-04-12 20:13:38 +0200
committerCharles <sircharlesaze@gmail.com>2020-04-12 20:13:38 +0200
commit1eb2d4832a590c809e38840f970b4506661c89cf (patch)
treefca2dd708d72b0f00ff550f163e2409301241a41 /test/ft_strlen_test.c
parent148e3a3a42a485c8a48ca49d32f23c0d97d41549 (diff)
downloadlibasm_test-1eb2d4832a590c809e38840f970b4506661c89cf.tar.gz
libasm_test-1eb2d4832a590c809e38840f970b4506661c89cf.tar.bz2
libasm_test-1eb2d4832a590c809e38840f970b4506661c89cf.zip
Printing ft_strlen and ft_strcmp arguments on failed test
Diffstat (limited to 'test/ft_strlen_test.c')
-rw-r--r--test/ft_strlen_test.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/test/ft_strlen_test.c b/test/ft_strlen_test.c
index 1c500ae..e92f668 100644
--- a/test/ft_strlen_test.c
+++ b/test/ft_strlen_test.c
@@ -6,19 +6,32 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/08 03:07:53 by cacharle #+# #+# */
-/* Updated: 2020/02/08 03:07:53 by cacharle ### ########.fr */
+/* Updated: 2020/04/12 20:08:55 by charles ### ########.fr */
/* */
/* ************************************************************************** */
#include "libasm_test.h"
+int actual;
+int expected;
+
+#define FT_STRLEN_EXPECT(str) do { \
+ actual = ft_strlen(str); \
+ expected = strlen(str); \
+ if (actual != expected) \
+ printf("KO: [COMPARE]: %s: expected: %d got: %d with: "#str"\n", \
+ test_name, expected, actual); \
+ else \
+ print_ok(); \
+} while (0);
+
static void
ft_strlen_test_segfault(void)
{
TEST_ASM_FUNCTION(ft_strlen(""));
TEST_ASM_FUNCTION(ft_strlen("bon"));
TEST_ASM_FUNCTION(ft_strlen("bonjour"));
- TEST_ASM_FUNCTION(ft_strlen("%c%s%p%x%X%e%f%g"));
+ TEST_ASM_FUNCTION(ft_strlen("asdfasdf''///##!!@"));
TEST_ASM_FUNCTION(ft_strlen("the\0hidden"));
TEST_ASM_FUNCTION(ft_strlen("Lorem ipsum dolor sit amet, consectetur adipiscing\
elit. Sed in malesuada purus. Etiam a scelerisque massa. Ut non euismod elit. Aliquam\
@@ -29,15 +42,13 @@ ac tortor et lectus fermentum lobortis eu at mauris. Vestibulum sit amet posuere
tortor, sit amet consequat amet."));
}
-#define FT_STRLEN_EXPECT(str) expect_int(strlen(str), ft_strlen(str))
-
static void
ft_strlen_test_compare(void)
{
FT_STRLEN_EXPECT("");
FT_STRLEN_EXPECT("bon");
FT_STRLEN_EXPECT("bonjour");
- FT_STRLEN_EXPECT("%c%s%p%x%X%e%f%g");
+ FT_STRLEN_EXPECT("asdfasdf''///##!!@");
FT_STRLEN_EXPECT("the\0hidden");
FT_STRLEN_EXPECT("Lorem ipsum dolor sit amet, consectetur adipiscing\
elit. Sed in malesuada purus. Etiam a scelerisque massa. Ut non euismod elit. Aliquam\