Evals w/ limits

This commit is contained in:
gbaconni
2022-04-29 23:41:56 +02:00
parent 9a0d970384
commit 8f86c1216c
3 changed files with 33 additions and 17 deletions

View File

@@ -6,7 +6,7 @@
# By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ # # By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2022/01/18 15:11:16 by gbaconni #+# #+# # # Created: 2022/01/18 15:11:16 by gbaconni #+# #+# #
# Updated: 2022/04/29 10:12:47 by gbaconni ### ########.fr # # Updated: 2022/04/29 23:22:57 by gbaconni ### lausanne.ch #
# # # #
# **************************************************************************** # # **************************************************************************** #
# #
@@ -22,6 +22,13 @@ GIT_REPO = git@vogsphere.42lausanne.ch:vogsphere/intra-uuid-fd8d00fc-8c22-400e-a
PDF_FR = https://cdn.intra.42.fr/pdf/pdf/50142/fr.subject.pdf PDF_FR = https://cdn.intra.42.fr/pdf/pdf/50142/fr.subject.pdf
PDF_EN = https://cdn.intra.42.fr/pdf/pdf/50141/en.subject.pdf PDF_EN = https://cdn.intra.42.fr/pdf/pdf/50141/en.subject.pdf
INT_MIN = "-2147483648"
INT_MAX = "2147483647"
UINT_MAX = "4294967295"
LONG_MIN = "-9223372036854775808"
LONG_MAX = "9223372036854775807"
ULONG_MAX = "18446744073709551615"
NAME = ft_printf NAME = ft_printf
LIBFTPRINTF = libftprintf LIBFTPRINTF = libftprintf
@@ -104,14 +111,23 @@ test: bonus
@$(PREFIX) ./$(NAME) "%s" "42 Lausanne" @$(PREFIX) ./$(NAME) "%s" "42 Lausanne"
@$(PREFIX) ./$(NAME) "%s" "" @$(PREFIX) ./$(NAME) "%s" ""
@$(PREFIX) ./$(NAME) "%d" 42 @$(PREFIX) ./$(NAME) "%d" 42
@$(PREFIX) ./$(NAME) "%i" 2147483647 @$(PREFIX) ./$(NAME) "%i" $(INT_MIN)
@$(PREFIX) ./$(NAME) "%i" -2147483646 @$(PREFIX) ./$(NAME) "%i" $(INT_MAX)
@$(PREFIX) ./$(NAME) "%u" 4294967295 @$(PREFIX) ./$(NAME) "%u" $(UINT_MAX)
@$(PREFIX) ./$(NAME) "%x" $(LONG_MIN)
@$(PREFIX) ./$(NAME) "%X" $(LONG_MIN)
@$(PREFIX) ./$(NAME) "%x" $(LONG_MAX)
@$(PREFIX) ./$(NAME) "%X" $(LONG_MAX)
@$(PREFIX) ./$(NAME) "%x" $(ULONG_MAX)
@$(PREFIX) ./$(NAME) "%X" $(ULONG_MAX)
@$(PREFIX) ./$(NAME) "%x" 42 @$(PREFIX) ./$(NAME) "%x" 42
@$(PREFIX) ./$(NAME) "%X" 42 @$(PREFIX) ./$(NAME) "%X" 42
@$(PREFIX) ./$(NAME) "%%" "" @$(PREFIX) ./$(NAME) "%%" ""
@$(PREFIX) ./$(NAME) "%p" "" @$(PREFIX) ./$(NAME) "%p" ""
@$(PREFIX) ./$(NAME) "%p" "\n" @$(PREFIX) ./$(NAME) "%p" "\n"
@$(PREFIX) ./$(NAME) "%p" $(LONG_MIN)
@$(PREFIX) ./$(NAME) "%p" $(LONG_MAX)
@$(PREFIX) ./$(NAME) "%p" $(ULONG_MAX)
@$(PREFIX) ./$(NAME) "Forty Two" "" @$(PREFIX) ./$(NAME) "Forty Two" ""
@$(PREFIX) ./$(NAME) "\t\r\n" "" @$(PREFIX) ./$(NAME) "\t\r\n" ""
@$(PREFIX) ./$(NAME) "%1d" 42 @$(PREFIX) ./$(NAME) "%1d" 42

View File

@@ -6,20 +6,20 @@
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */ /* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/16 13:51:16 by gbaconni #+# #+# */ /* Created: 2021/08/16 13:51:16 by gbaconni #+# #+# */
/* Updated: 2022/04/18 09:13:04 by gbaconni ### lausanne.ch */ /* Updated: 2022/04/29 23:39:15 by gbaconni ### lausanne.ch */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "ft_printf.h" #include "ft_printf.h"
static long ft_ltoa_base_len(long n, long nbase); static long long ft_ltoa_base_len(long long n, long long nbase);
char *ft_ltoa_base(long n, char *base) char *ft_ltoa_base(long n, char *base)
{ {
char *s; char *s;
int i; long long i;
long nbr; long long nbr;
long nbase; long long nbase;
nbase = ft_strlen(base); nbase = ft_strlen(base);
s = (char *) ft_calloc(ft_ltoa_base_len(n, nbase) + 1, sizeof(char)); s = (char *) ft_calloc(ft_ltoa_base_len(n, nbase) + 1, sizeof(char));
@@ -42,9 +42,9 @@ char *ft_ltoa_base(long n, char *base)
return (ft_strrev(s)); return (ft_strrev(s));
} }
static long ft_ltoa_base_len(long n, long nbase) static long long ft_ltoa_base_len(long long n, long long nbase)
{ {
size_t len; long long len;
len = 0; len = 0;
if (n < 0 || n == 0) if (n < 0 || n == 0)

10
main.c
View File

@@ -6,14 +6,14 @@
/* By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ */ /* By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/13 06:58:46 by gbaconni #+# #+# */ /* Created: 2022/04/13 06:58:46 by gbaconni #+# #+# */
/* Updated: 2022/04/29 17:50:00 by gbaconni ### ########.fr */ /* Updated: 2022/04/29 22:52:28 by gbaconni ### lausanne.ch */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include <stdio.h> // printf #include <stdio.h>
#include <string.h> // strlen #include <string.h>
#include <ctype.h> // isdigit #include <assert.h>
#include <assert.h> // assert #include <limits.h>
#include "libftprintf/ft_printf.h" #include "libftprintf/ft_printf.h"