42 lines
1.3 KiB
C
42 lines
1.3 KiB
C
#include "tests.h"
|
|
char *ft_strncpy(char*, char*, size_t);
|
|
int main(void)
|
|
{
|
|
char s1[100] = TEST_SOURCE;
|
|
char d1[100] = TEST_DESTINATION;
|
|
char*r1;
|
|
char s2[100] = TEST_SOURCE;
|
|
char d2[100] = TEST_DESTINATION;
|
|
char*r2;
|
|
char s3[100] = TEST_SOURCE;
|
|
char d3[100] = TEST_DESTINATION;
|
|
char*r3;
|
|
char s4[100] = TEST_SOURCE;
|
|
char d4[100] = TEST_DESTINATION;
|
|
char*r4;
|
|
|
|
|
|
printf("initial strings:\n");
|
|
dump(s1, TEST_SOURCE_LENGHT);
|
|
dump(d1, TEST_DESTINATION_LENGHT);
|
|
r1 = strncpy(d1 ,s1, 4);
|
|
printf("strncpy(d, s, 4):\n");
|
|
dump(s1, TEST_SOURCE_LENGHT);
|
|
dump(d1, TEST_DESTINATION_LENGHT);
|
|
r2 = ft_strncpy(d2, s2, 4);
|
|
printf("ft_strncpy(d, s, 4:\n");
|
|
dump(s2, TEST_SOURCE_LENGHT);
|
|
dump(d2, TEST_DESTINATION_LENGHT);
|
|
printf("buffers comparison: s:%i d:%i\n", bufcmp(s1, s2, TEST_SOURCE_LENGHT), bufcmp(d1, d2, TEST_DESTINATION_LENGHT));
|
|
r3 = strncpy(d3 ,s3, 20);
|
|
printf("strncpy(d, s, 20):\n");
|
|
dump(s3, TEST_SOURCE_LENGHT);
|
|
dump(d3, TEST_DESTINATION_LENGHT);
|
|
r4 = ft_strncpy(d4, s4, 20);
|
|
printf("ft_strncpy(d, s, 20):\n");
|
|
dump(s4, TEST_SOURCE_LENGHT);
|
|
dump(d4, TEST_DESTINATION_LENGHT);
|
|
printf("buffers comparison: s:%i d:%i\n", bufcmp(s3, s4, TEST_SOURCE_LENGHT), bufcmp(d3, d4, TEST_DESTINATION_LENGHT));
|
|
printf("return values comparison: %li %li %li %li\n", d1 - r1, d2 -r2, d3 - r3, d4 - r4);
|
|
}
|