ft_memmove()
This commit is contained in:
parent
d64354612b
commit
95e346c2ee
3 changed files with 69 additions and 3 deletions
8
Makefile
8
Makefile
|
|
@ -6,7 +6,7 @@
|
|||
# By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2025/10/03 18:03:12 by lalgarra #+# #+# #
|
||||
# Updated: 2025/10/05 13:30:04 by lalgarra ### ########.fr #
|
||||
# Updated: 2025/10/05 14:09:02 by lalgarra ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
@ -14,11 +14,13 @@
|
|||
LIBDIR = ../repo_libft_algarra
|
||||
#LIBDIR = ../vogsphere_repo
|
||||
|
||||
CFLAGS += -Wall -Wextra -Werror -g3 -iquote $(LIBDIR)
|
||||
CFLAGS += -Wall -Wextra -Werror -g3 -iquote $(LIBDIR) \
|
||||
-fsanitize=address -Wanalyzer-malloc-leak
|
||||
|
||||
TESTS := ft_isalpha_test ft_isdigit_test ft_isalnum_test ft_isascii_test \
|
||||
ft_isprint_test ft_toupper_test ft_tolower_test ft_strlen_test \
|
||||
ft_memset_test ft_bzero_test ft_memcpy_test ft_calloc_test
|
||||
ft_memset_test ft_bzero_test ft_memcpy_test ft_calloc_test \
|
||||
ft_memmove_test
|
||||
|
||||
%_test : %_test.c
|
||||
$(CC) $(CFLAGS) $*_test.c -L$(LIBDIR) -lft -o $*_test
|
||||
|
|
|
|||
2
ft_memmove_expected.output
Normal file
2
ft_memmove_expected.output
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
test 1:
|
||||
Lorem ipsum dolor si; Lorem iLorem ipsu si
|
||||
62
ft_memmove_test.c
Normal file
62
ft_memmove_test.c
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_memmove_test.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/05 13:21:43 by lalgarra #+# #+# */
|
||||
/* Updated: 2025/10/05 14:02:12 by lalgarra ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
static void do_test3(char *prefix)
|
||||
{
|
||||
int *buff;
|
||||
size_t buflen;
|
||||
size_t size;
|
||||
|
||||
buflen = 5;
|
||||
size = 0;
|
||||
buff = ft_calloc(buflen, size);
|
||||
printf("%ssize= %lu; buff == NULL: %i\n", prefix, size, buff == NULL);
|
||||
free(buff);
|
||||
}
|
||||
|
||||
static void do_test2(char *prefix)
|
||||
{
|
||||
int *buff;
|
||||
size_t buflen;
|
||||
|
||||
buflen = 0;
|
||||
buff = ft_calloc(buflen, sizeof(int));
|
||||
printf("%sbuflen = %lu; buff == NULL: %i\n", prefix, buflen, buff == NULL);
|
||||
free(buff);
|
||||
}
|
||||
*/
|
||||
static void do_test1(char *prefix)
|
||||
{
|
||||
char buf[128];
|
||||
int fd;
|
||||
|
||||
fd = STDOUT_FILENO;
|
||||
ft_bzero(buf, 128);
|
||||
ft_memcpy(buf, "Lorem ipsum dolor sit amet consectetur adipiscing elit.", 20);
|
||||
ft_putstr_fd(prefix, fd);
|
||||
ft_putchar_fd('\n', fd);
|
||||
ft_putstr_fd(buf, fd);
|
||||
ft_putstr_fd("; ", fd);
|
||||
ft_memmove(buf + 7, buf, 10);
|
||||
ft_putendl_fd(buf, fd);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
do_test1("test 1: ");
|
||||
return (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue