Add: itao + strdup tests
This commit is contained in:
26
real_tests/ft_strdup/00_launcher.c
Normal file
26
real_tests/ft_strdup/00_launcher.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 00_launcher.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/25 16:56:28 by dgaillet #+# #+# */
|
||||
/* Updated: 2026/01/25 16:56:28 by dgaillet ### ########lyon.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../tests.h"
|
||||
|
||||
int strdup_launcher(void)
|
||||
{
|
||||
t_unit_test *testlist;
|
||||
size_t res;
|
||||
|
||||
testlist = NULL;
|
||||
load_test(&testlist, "Basic test", &strdup_basic_test, 0);
|
||||
load_test(&testlist, "Basic test", &strdup_null_test, 0);
|
||||
res = launch_tests(testlist, "strdup");
|
||||
clear_tests(&testlist);
|
||||
return (res);
|
||||
}
|
||||
25
real_tests/ft_strdup/01_basic.c
Normal file
25
real_tests/ft_strdup/01_basic.c
Normal file
@@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 01_basic.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/25 17:10:35 by dgaillet #+# #+# */
|
||||
/* Updated: 2026/01/25 17:10:36 by dgaillet ### ########lyon.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../tests.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
int strdup_basic_test(void)
|
||||
{
|
||||
char *str;
|
||||
int res;
|
||||
|
||||
str = ft_strdup("Hello, World !");
|
||||
res = ft_strncmp(str, "Hello, World !", 14);
|
||||
free(str);
|
||||
return (res);
|
||||
}
|
||||
24
real_tests/ft_strdup/02_null.c
Normal file
24
real_tests/ft_strdup/02_null.c
Normal file
@@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 02_null.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/25 17:10:43 by dgaillet #+# #+# */
|
||||
/* Updated: 2026/01/25 17:10:44 by dgaillet ### ########lyon.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../tests.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
int strdup_null_test(void)
|
||||
{
|
||||
char *str;
|
||||
|
||||
str = ft_strdup(NULL);
|
||||
if (str)
|
||||
free(str);
|
||||
return (1);
|
||||
}
|
||||
Reference in New Issue
Block a user