aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile29
-rw-r--r--README.md9
-rw-r--r--generate.py8
-rw-r--r--tests/pft_tests.c50
4 files changed, 65 insertions, 31 deletions
diff --git a/Makefile b/Makefile
index a338d11..fe5a84a 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@
# By: cacharle <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/02/06 18:13:15 by cacharle #+# #+# #
-# Updated: 2020/02/06 18:13:19 by cacharle ### ########.fr #
+# Updated: 2020/02/06 19:50:23 by cacharle ### ########.fr #
# #
# **************************************************************************** #
@@ -20,7 +20,7 @@ NAME = ft_printf_test
CHECK_LEAKS_NAME = check_leaks
PYTHON = python3
RM = rm -f
-MAKE = make -j4
+MAKE = make
SRC = main.c helper.c tests/pft_tests.c tests/moulitest_tests.c tests/printf_tester_tests.c \
tests/printf_tests_tests.c saved_tests.c generated.c
@@ -29,24 +29,39 @@ OBJ = $(SRC:.c=.o)
run: all
./$(NAME) | $(PYTHON) prettier.py
+runbonus: allbonus run
+
verbose: all
./$(NAME) | $(PYTHON) prettier.py --verbose
+verbosebonus: allbonus verbose
+
quiet: all
./$(NAME) | $(PYTHON) prettier.py --quiet
+quietbonus: allbonus quiet
+
no_clear: all
./$(NAME) | $(PYTHON) prettier.py --no-clear
+no_clearbonus: allbonus no_clear
+
interactive: all
./$(NAME) | $(PYTHON) prettier.py --interactive
+interactivebonus: allbonus interactive
+
raw: all
./$(NAME)
+rawbonus: allbonus raw
+
generate:
$(PYTHON) generate.py -n 100
+generatebonus:
+ $(PYTHON) generate.py -n 100 --bonus
+
.PHONY: check_leaks
check_leaks:
$(CC) $(LDFLAGS) $(CCFLAGS) -g -o $(CHECK_LEAKS_NAME) check_leaks.c
@@ -57,9 +72,12 @@ check_leaks_verbose:
valgrind --leak-check=full ./$(CHECK_LEAKS_NAME) > /dev/null
-all: $(NAME)
+all: ft_printf_all $(NAME)
-$(NAME): ft_printf_all $(OBJ) header.h tests/tests.h
+allbonus: CCFLAGS += -D FT_PRINTF_TEST_BONUS
+allbonus: ft_printf_all ft_printf_bonus $(NAME)
+
+$(NAME): $(OBJ) header.h tests/tests.h
$(CC) $(LDFLAGS) $(CCFLAGS) -o $@ $(OBJ)
%.o: %.c
@@ -78,3 +96,6 @@ re: fclean all
ft_printf_all:
$(MAKE) -C $(FT_PRINTF_PATH) all
+
+ft_printf_bonus:
+ $(MAKE) -C $(FT_PRINTF_PATH) bonus
diff --git a/README.md b/README.md
index 9c944e2..0daa08a 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,10 @@ or modify the `FT_PRINTF_PATH` variable in the Makefile
- `> python3 prettier -h`: show prettier options
- `> make generate`: generate 100 random test
+### Bonus
+
+All the previous `make` command suffixed with `bonus` (i.e `make runbonus`). You may need
+to `make fclean` in order to clean the previous .o files.
## Random Test Generator
@@ -31,6 +35,10 @@ It will generate random test according to the `-Wformat` flag of gcc.
- `> python3 generate.py -n [number of tests]`: generate n test
- `> python3 generate.py -h`: show all available options
+### Bonus
+
+Add the `--bonus` flag i.e: `> python3 generate.py -n [number of tests] --bonus`.
+
## Memory leaks check
You have to install [valgrind](http://valgrind.org/) with [brew](https://brew.sh/),
@@ -52,3 +60,4 @@ this test will too.
- [pft](https://github.com/gavinfielder/pft) by gavinfielder
- [printf\_tester](https://github.com/AntoineBourin/printf-tester) by AntoineBourin
- [printf\_tests](https://github.com/BartMassey/printf-tests) by BartMassey
+- @MrHade for the no bonus test.
diff --git a/generate.py b/generate.py
index 9dc114d..b727133 100644
--- a/generate.py
+++ b/generate.py
@@ -6,7 +6,7 @@
# By: cacharle <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/02/06 18:13:26 by cacharle #+# #+# #
-# Updated: 2020/02/06 18:13:28 by cacharle ### ########.fr #
+# Updated: 2020/02/06 19:36:46 by cacharle ### ########.fr #
# #
# **************************************************************************** #
@@ -40,6 +40,7 @@ def parse_args():
parser.add_argument("-a", "--args-max", default=5, type=int, help="maximum number of argument")
parser.add_argument("-f", "--flags-max", default=3, type=int, help="maximum number of flags")
parser.add_argument("-s", "--str-max", default=30, type=int, help="maximum length of string")
+ parser.add_argument("--bonus", action="store_true", help="generate with bonus flags")
return vars(parser.parse_args(sys.argv[1:]))
@@ -60,8 +61,11 @@ class Generator:
self.precision_wildcard_rate = 10
self.precision_empty_rate = 2
self.precision_point_rate = 4
- self.possible_flags = "#0- +'"
self.possible_conv ="diuxXcsp%"
+ if options["bonus"]:
+ self.possible_flags = "#0- +'"
+ else:
+ self.possible_flags = "0-"
self.possible_conv_len = len(self.possible_conv)
self.pool = []
diff --git a/tests/pft_tests.c b/tests/pft_tests.c
index 2fae788..0b9f030 100644
--- a/tests/pft_tests.c
+++ b/tests/pft_tests.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/06 18:15:10 by cacharle #+# #+# */
-/* Updated: 2020/02/06 19:24:49 by cacharle ### ########.fr */
+/* Updated: 2020/02/06 19:52:26 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -53,7 +53,7 @@ void test_pft_nocrash(void)
ASSERT_PRINTF("%hp", &ncm_p);
ASSERT_PRINTF("%lp", &ncm_p);
ASSERT_PRINTF("%llp", &ncm_p);
- ASSERT_PRINTF("%Lp", &ncm_p);*/
+ ASSERT_PRINTF("%Lp", &ncm_p);
ASSERT_PRINTF("%-p", &ncm_p);
ASSERT_PRINTF("%Ld", 42);
ASSERT_PRINTF("%#d", 42);
@@ -86,7 +86,7 @@ void test_pft_nocrash(void)
ASSERT_PRINTF("%hhlu", 42);
ASSERT_PRINTF("%hhllu", 42);
ASSERT_PRINTF("%llhu", 42);
- ASSERT_PRINTF("%lllu", 42);*/
+ ASSERT_PRINTF("%lllu", 42);
ASSERT_PRINTF("%-u", 42);
ASSERT_PRINTF("%Lx", 42);
ASSERT_PRINTF("%+x", 42);
@@ -174,18 +174,18 @@ void test_pft_nocrash(void)
ASSERT_PRINTF("%h");
ASSERT_PRINTF("%ll");
ASSERT_PRINTF("%l");
- ASSERT_PRINTF("%L");*/
+ ASSERT_PRINTF("%L");
ASSERT_PRINTF("%f");
ASSERT_PRINTF("%o");
- ASSERT_PRINTF("%1$s", NULL);*/
+ ASSERT_PRINTF("%1$s", NULL);
ASSERT_PRINTF("% s", NULL);
- ASSERT_PRINTF("%#s", NULL);*/
+ ASSERT_PRINTF("%#s", NULL);
ASSERT_PRINTF("%+s", NULL);
ASSERT_PRINTF("%hhs", NULL);
ASSERT_PRINTF("%hs", NULL);
ASSERT_PRINTF("%lls", NULL);
ASSERT_PRINTF("%ls", NULL);
- ASSERT_PRINTF("%Ls", NULL);*/
+ ASSERT_PRINTF("%Ls", NULL);
ASSERT_PRINTF("%b", NULL);
ASSERT_PRINTF("%f", NULL);
ASSERT_PRINTF("%o", NULL);
@@ -390,6 +390,15 @@ void test_pft_string(void)
void test_pft_int_i(void)
{
+ static char ch_pos_1 = 100, ch_neg_1 = -87;
+ static short sh_pos_1 = 3047, sh_neg_1 = -8875;
+ static int i_pos_1 = 878023;
+ static long l_pos_1 = 22337203685477, l_neg_1 = -22337203685477;
+ static long long ll_pos_1 = 22337203685477, ll_neg_1 = -22337203685477;
+ static long lmax = 9223372036854775807;
+ static long lmin = -9223372036854775807;
+ static long long llmax = 9223372036854775807;
+ static long long llmin = -9223372036854775807ll;
ASSERT_PRINTF("this %i number", 17);
ASSERT_PRINTF("this %i number", -267);
ASSERT_PRINTF("this %i number", 0);
@@ -717,15 +726,6 @@ void test_pft_int_i(void)
ASSERT_PRINTF("%0-3.7i", -2375);
ASSERT_PRINTF("%0-3.3i", 6983);
ASSERT_PRINTF("%0-3.3i", -8462);
- static char ch_pos_1 = 100, ch_neg_1 = -87;
- static short sh_pos_1 = 3047, sh_neg_1 = -8875;
- static int i_pos_1 = 878023;
- static long l_pos_1 = 22337203685477, l_neg_1 = -22337203685477;
- static long long ll_pos_1 = 22337203685477, ll_neg_1 = -22337203685477;
- static long lmax = 9223372036854775807;
- static long lmin = -9223372036854775807;
- static long long llmax = 9223372036854775807;
- static long long llmin = -9223372036854775807ll;
ASSERT_PRINTF("%.0i", 0);
ASSERT_PRINTF("%.i", 0);
ASSERT_PRINTF("%5.0i", 0);
@@ -736,6 +736,15 @@ void test_pft_int_i(void)
void test_pft_int_d(void)
{
+ static char ch_pos_1 = 100, ch_neg_1 = -87;
+ static short sh_pos_1 = 3047, sh_neg_1 = -8875;
+ static int i_pos_1 = 878023;
+ static long l_pos_1 = 22337203685477, l_neg_1 = -22337203685477;
+ static long long ll_pos_1 = 22337203685477, ll_neg_1 = -22337203685477;
+ static long lmax = 9223372036854775807;
+ static long lmin = -9223372036854775807;
+ static long long llmax = 9223372036854775807;
+ static long long llmin = -9223372036854775807ll;
#ifdef FT_PRINTF_TEST_BONUS
ASSERT_PRINTF("this %d number", 17);
ASSERT_PRINTF("this %d number", -267);
@@ -1043,15 +1052,6 @@ void test_pft_int_d(void)
ASSERT_PRINTF("%-3.3d", 6983);
ASSERT_PRINTF("%-3.3d", -8462);
- static char ch_pos_1 = 100, ch_neg_1 = -87;
- static short sh_pos_1 = 3047, sh_neg_1 = -8875;
- static int i_pos_1 = 878023;
- static long l_pos_1 = 22337203685477, l_neg_1 = -22337203685477;
- static long long ll_pos_1 = 22337203685477, ll_neg_1 = -22337203685477;
- static long lmax = 9223372036854775807;
- static long lmin = -9223372036854775807;
- static long long llmax = 9223372036854775807;
- static long long llmin = -9223372036854775807ll;
ASSERT_PRINTF("%08.5d", 34);
ASSERT_PRINTF("%010.5d", -216);