Initial commit
This commit is contained in:
commit
6fa86c0a44
2 changed files with 165 additions and 0 deletions
97
Makefile
Normal file
97
Makefile
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
# **************************************************************************** #
|
||||
# #
|
||||
# ::: :::::::: #
|
||||
# Makefile :+: :+: :+: #
|
||||
# +:+ +:+ +:+ #
|
||||
# By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2025/10/15 18:42:55 by lalgarra #+# #+# #
|
||||
# Updated: 2025/10/15 19:28:30 by lalgarra ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
NAME = test_printf
|
||||
|
||||
# Relative location of your libftprintf.a, Makefile and sources
|
||||
LIBDIR = ../repo_algarra
|
||||
#LIBDIR = ../vogsphere_repo
|
||||
|
||||
SOURCES = test_printf.c
|
||||
|
||||
OBJECTS = $(SOURCES:.c=.o)
|
||||
|
||||
CFLAGS += -Wall -Wextra -Werror -g3 -iquote $(LIBDIR) -O0
|
||||
|
||||
$(NAME): $(OBJECTS) $(LIBDIR)/libftprintf.a
|
||||
$(CC) $(CFLAGS) $(OBJECTS) -L$(LIBDIR) -lftprintf -o $(NAME)
|
||||
|
||||
$(LIBDIR)/libftprintf.a:
|
||||
$(MAKE) -C $(LIBDIR) all
|
||||
|
||||
.PHONY: clean fclean re
|
||||
|
||||
clean:
|
||||
#removes objects (.o)#
|
||||
rm -f $(OBJECTS)
|
||||
$(MAKE) -C $(LIBDIR) clean
|
||||
|
||||
fclean: clean
|
||||
#removes objects (.o) and library#
|
||||
rm -f $(NAME)
|
||||
$(MAKE) -C $(LIBDIR) fclean
|
||||
|
||||
all: $(NAME)
|
||||
# builds all
|
||||
|
||||
re: fclean all
|
||||
# cleans and rebuild all
|
||||
|
||||
#
|
||||
#CFLAGS += -Wall -Wextra -Werror -g3 -iquote $(LIBDIR) \
|
||||
# -O0
|
||||
#
|
||||
#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_memmove_test ft_strlcpy_test ft_strlcat_test ft_strchr_test \
|
||||
# ft_strrchr_test ft_strncmp_test ft_memcmp_test ft_strnstr_test \
|
||||
# ft_atoi_test ft_substr_test ft_strjoin_test ft_strtrim_test \
|
||||
# ft_split_test
|
||||
#
|
||||
#TESTSBONUS := ft_lstclear_test
|
||||
#
|
||||
#%_test : %_test.c
|
||||
# $(CC) $(CFLAGS) $*_test.c -L$(LIBDIR) -lft -o $*_test
|
||||
#
|
||||
#%_actual.output : %_test
|
||||
# @./$*_test 2>&1 > ./$*_actual.output ;
|
||||
#
|
||||
##alternative command
|
||||
## @script -qc './$*_test &> ./$*_actual.output' 2> ./$*_actual.output 1> /dev/null
|
||||
#
|
||||
#%_report : %_test %_actual.output
|
||||
# -(diff -a $*_expected.output $*_actual.output \
|
||||
# && echo "Test OK") > $*_report
|
||||
#
|
||||
#EXES = $(TESTS)
|
||||
#
|
||||
#ACT_OUTPUTS = $(TESTS:_test=_actual.output)
|
||||
#
|
||||
#ACT_REPORTS = $(TESTS:_test=_report)
|
||||
#
|
||||
#.SECONDARY = $(ACT_REPORTS) $(ACT_OUTPUTS)
|
||||
#
|
||||
## Rule to create a 'report' file with info about the execution of
|
||||
## tests in $(TEST)
|
||||
#report : $(EXES) $(ACT_OUTPUTS) $(ACT_REPORTS)
|
||||
# @rm -f report ;
|
||||
# @$(foreach E, $(TESTS), \
|
||||
# $(eval T = $(subst _test,,$(E))) \
|
||||
# $(eval R = $(subst _test,_report,$(E))) \
|
||||
# echo "=== $(T) ===" >> report ; \
|
||||
# cat $(R) >> report ; \
|
||||
# )
|
||||
#
|
||||
#fclean:
|
||||
# rm -f report $(ACT_REPORTS) $(ACT_OUTPUTS) $(EXES)
|
||||
#
|
||||
68
test_printf.c
Normal file
68
test_printf.c
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_printf.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/15 18:54:32 by lalgarra #+# #+# */
|
||||
/* Updated: 2025/10/15 19:27:35 by lalgarra ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libftprintf.h"
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static char *get_begin(void)
|
||||
{
|
||||
return "%s printf() output: [BEGIN]";
|
||||
}
|
||||
|
||||
static char *get_ftbegin(void)
|
||||
{
|
||||
return "%s ft_printf() output: [BEGIN]";
|
||||
}
|
||||
|
||||
static char *get_end(void)
|
||||
{
|
||||
return "[END]; returns: %i\n";
|
||||
}
|
||||
|
||||
static void call_printf(const char *prefix, const char *sfmt, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list args;
|
||||
|
||||
printf(get_begin(), prefix);
|
||||
va_start(args, sfmt);
|
||||
ret = vprintf(sfmt, args);
|
||||
va_end(args);
|
||||
printf(get_end(), ret);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
static void test01()
|
||||
{
|
||||
char prefix[128];
|
||||
char sfmt[128];
|
||||
char arg1[128];
|
||||
int ret;
|
||||
|
||||
strcpy(prefix, "test01: ");
|
||||
strcpy(sfmt, "Hola %s Mundo");
|
||||
strcpy(arg1, "Es%sto es una \xfa prueba");
|
||||
call_printf(prefix, sfmt, arg1);
|
||||
printf(get_ftbegin(), prefix);
|
||||
fflush(stdout);
|
||||
ret = ft_printf(sfmt, arg1);
|
||||
printf(get_end(), ret);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
test01();
|
||||
return (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue