Test against std

This commit is contained in:
tosu 2023-03-30 19:27:05 +02:00
parent 49321cea4a
commit cf02c2d576
1 changed files with 24 additions and 0 deletions

View File

@ -33,6 +33,7 @@ char *ft_strdup(char *src)
/* ////
#include <stdio.h>
#include <string.h>
int main(void)
{
@ -42,7 +43,14 @@ int main(void)
char *str2;
char *str3;
char *str4;
char *str_std1;
char *str_stda;
char *str_stdb;
char *str_std2;
char *str_std3;
char *str_std4;
printf("### Testing ft_strdup ###\n");
str1 = "The String";
stra = "The String";
strb = str1;
@ -58,6 +66,22 @@ int main(void)
free(str2);
free(str3);
free(str4);
printf("\n### Testing strdup ###\n");
str_std1 = "The Standard String";
str_stda = "The Standard String";
str_stdb = str_std1;
str_std2 = strdup(str_std1);
str_std3 = strdup(str_std1);
str_std4 = strdup(str_std2);
printf("str_std1 value: %s, str_std1 address: %p\n", str_std1, str_std1);
printf("str_stda value: %s, str_stda address: %p (==str_std1)\n", str_stda, str_stda);
printf("str_stdb value: %s, str_stdb address: %p (==str_std1)\n", str_stdb, str_stdb);
printf("str_std2 value: %s, str_std2 address: %p (diff)\n", str_std2, str_std2);
printf("str_std3 value: %s, str_std3 address: %p (diff)\n", str_std3, str_std3);
printf("str_std4 value: %s, str_std4 address: %p (diff)\n", str_std4, str_std4);
free(str_std2);
free(str_std3);
free(str_std4);
return (0);
}
*/ ////