Skip to content

Commit dc3f1dc

Browse files
committed
use ft_ functions in test.c
1 parent 5551e7c commit dc3f1dc

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

test.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,35 @@
66
#include <string.h>
77

88
int main() {
9-
// 1. Basic functionality tests
109
char *str = (char *)malloc(20);
1110
assert(str != NULL);
12-
strcpy(str, "42helloworld");
11+
ft_strlcpy(str, "42helloworld", 20);
1312
assert(strcmp(str, "42helloworld") == 0);
13+
ft_bzero(str, 20);
1414
free(str);
1515

1616
int *arr = (int *)calloc(5, sizeof(int));
1717
assert(arr != NULL);
1818
for (int i = 0; i < 5; i++) {
1919
assert(arr[i] == 0);
2020
}
21+
ft_bzero(arr, 5 * sizeof(int));
2122
free(arr);
2223

2324
char *dynstr = (char *)malloc(5);
2425
assert(dynstr != NULL);
25-
strcpy(dynstr, "Test");
26+
ft_strlcpy(dynstr, "Test", 5);
2627
dynstr = realloc(dynstr, 10);
27-
strcat(dynstr, "1234");
28-
assert(strcmp(dynstr, "Test1234") == 0);
28+
ft_strlcat(dynstr, "1234", 10);
29+
assert(ft_strcmp(dynstr, "Test1234") == 0);
30+
ft_bzero(dynstr, 10);
2931
free(dynstr);
3032

3133
void *edge1 = malloc(0);
3234
free(edge1);
3335

3436
char *edge2 = (char *)malloc(5);
37+
ft_bzero(edge2, 5);
3538
edge2 = realloc(edge2, 0);
3639
assert(edge2 == NULL);
3740

0 commit comments

Comments
 (0)