test(base)
This commit is contained in:
parent
f091b6c53a
commit
2419433d71
|
@ -1,4 +1,7 @@
|
|||
*.o
|
||||
*.a
|
||||
*.swp
|
||||
test
|
||||
|
||||
test_bonus
|
||||
|
||||
libasm_unit_tests
|
||||
|
|
5
Makefile
5
Makefile
|
@ -28,6 +28,9 @@ all: $(NAME)
|
|||
bonus: $(OBJ) $(OBJBONUS)
|
||||
ar rcs libasm.a $(OBJ) $(OBJBONUS)
|
||||
|
||||
test: all
|
||||
gcc -Wall -Werror -Wextra -pie main.c -L . -lasm -o test
|
||||
|
||||
test_bonus: bonus
|
||||
gcc -Wall -Werror -Wextra -pie main_bonus.c -L . -lasm -o test_bonus
|
||||
|
||||
|
@ -39,6 +42,8 @@ clean:
|
|||
|
||||
fclean: clean
|
||||
rm -fv libasm.a
|
||||
rm -fv test
|
||||
rm -fv test_bonus
|
||||
|
||||
re: fclean all
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include "libasm.h"
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int main(void) {
|
||||
char *str = ft_strdup("abcdefghi\n");
|
||||
char *str2 = ft_strdup("a34\n");
|
||||
assert(strcmp(str, "abcdefghi\n") == 0);
|
||||
assert(ft_strcmp(str, str2) == 47);
|
||||
assert(strlen(str) == ft_strlen(str));
|
||||
assert(strlen(str2) == ft_strlen(str2));
|
||||
char *str3 = malloc(sizeof(char) * (1 + ft_strlen(str2)));
|
||||
ft_strcpy(str3, str2);
|
||||
assert(strcmp(str3, str2) == 0);
|
||||
assert(ft_strcmp(str3, str2) == strcmp(str3, str2));
|
||||
free(str);
|
||||
ft_write(1, str2, ft_strlen(str2));
|
||||
free(str2);
|
||||
free(str3);
|
||||
int fd = open("Makefile", O_RDONLY);
|
||||
if (fd != -1) {
|
||||
char *buf = malloc(128 * sizeof(char));
|
||||
int ret = ft_read(fd, buf, 128);
|
||||
ft_write(1, buf, ret);
|
||||
ft_write(1, "\n", 1);
|
||||
close(fd);
|
||||
free(buf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -21,6 +21,12 @@ void test_ft_list(void) {
|
|||
assert(ft_strcmp(list->data, "zzz") == 0);
|
||||
ft_list_sort(&list, &ft_strcmp);
|
||||
assert(ft_strcmp(list->data, "cdb") == 0);
|
||||
|
||||
ft_list_remove_if(&list, (void *)"cdb", &ft_strcmp, &free);
|
||||
ft_list_remove_if(&list, (void *)"zzz", &ft_strcmp, &free);
|
||||
ft_list_remove_if(&list, (void *)"egh", &ft_strcmp, &free);
|
||||
ft_list_remove_if(&list, (void *)"dgb", &ft_strcmp, &free);
|
||||
ft_list_remove_if(&list, (void *)"egb", &ft_strcmp, &free);
|
||||
}
|
||||
|
||||
void test_ft_atoi_base(void) {
|
||||
|
|
BIN
test_bonus
BIN
test_bonus
Binary file not shown.
Loading…
Reference in New Issue