Testing NULL/nil cases

This commit is contained in:
lalgarra 2025-10-17 20:56:42 +02:00
parent bbf238e36d
commit 166c588f7a

View file

@ -6,7 +6,7 @@
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */ /* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/10/15 18:54:32 by lalgarra #+# #+# */ /* Created: 2025/10/15 18:54:32 by lalgarra #+# #+# */
/* Updated: 2025/10/17 18:46:01 by lalgarra ### ########.fr */ /* Updated: 2025/10/17 20:22:55 by lalgarra ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -95,6 +95,23 @@ static void test03()
test_int(prefix, sfmt, 9123325); test_int(prefix, sfmt, 9123325);
} }
static void test04()
{
char prefix[128];
char sfmt[128];
int ret;
strcpy(prefix, "test04: ");
strcpy(sfmt, "%%s: NULL %s NULL; %%p: %p %p --eof; ");
printf("%s printf(): ", prefix);
ret = printf(sfmt, NULL, 0, 0);
printf("ret=%i\n", ret);
fflush(stdout);
ft_printf("%sft_printf(): ", prefix);
ret = ft_printf(sfmt, NULL, 0, 0);
ft_printf("ret=%i\n", ret);
}
static void test99() static void test99()
{ {
char prefix[128]; char prefix[128];
@ -103,11 +120,11 @@ static void test99()
strcpy(prefix, "test99: "); strcpy(prefix, "test99: ");
strcpy(sfmt, "%%c: %c; %%s: %s; %%p: %p; %%d: %d; %%i: %i; %%u: %u; %%x: %x; %%X: %X --eof; "); strcpy(sfmt, "%%c: %c; %%s: %s; %%p: %p; %%d: %d; %%i: %i; %%u: %u; %%x: %x; %%X: %X --eof; ");
printf("%s: ", prefix); printf("%s printf(): ", prefix);
ret = printf(sfmt, 'a', "Lorem ipsum", (void *)prefix, 125, -128, 325u, 0xfa, 0xfb); ret = printf(sfmt, 'a', "Lorem ipsum", (void *)prefix, 125, -128, 325u, 0xfa, 0xfb);
printf("ret=%i\n", ret); printf("ret=%i\n", ret);
fflush(stdout); fflush(stdout);
ft_printf("%s: ", prefix); ft_printf("%sft_printf(): ", prefix);
ret = ft_printf(sfmt, 'a', "Lorem ipsum", (void *)prefix, 125, -128, 325u, 0xfa, 0xfb); ret = ft_printf(sfmt, 'a', "Lorem ipsum", (void *)prefix, 125, -128, 325u, 0xfa, 0xfb);
ft_printf("ret=%i\n", ret); ft_printf("ret=%i\n", ret);
} }
@ -117,6 +134,7 @@ int main(void)
test01(); test01();
test02(); test02();
test03(); test03();
test04();
test99(); test99();
return (0); return (0);
} }