GCC Code Coverage Report


Directory: ./
File: lib/my/my_printf/flag_f.c
Date: 2024-06-05 00:34:38
Exec Total Coverage
Lines: 15 15 100.0%
Functions: 2 2 100.0%
Branches: 4 4 100.0%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2023
3 ** my_printf
4 ** File description:
5 ** Flag to print a %f (a double)
6 */
7 /**
8 * @file flag_f.c
9 * @brief The file containing the flag_f function
10 * @author Nicolas TORO
11 */
12
13 #include "myprintf.h"
14
15 18 static char *my_get_str_float(double nb, formating_t *formating)
16 {
17 18 long long int partie_entiere = ABS((int)nb);
18
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17 times.
18 double partie_d = ABS(nb - partie_entiere);
19 18 char *str_finale = malloc(sizeof(char) * 1000000);
20
21 18 str_finale[0] = '\0';
22
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17 times.
18 if (nb < 0)
23 1 my_strcat(str_finale, "-");
24 18 my_strcat(str_finale, my_str_nbr_long_long(partie_entiere));
25 18 precise_it_double(str_finale, formating, partie_d);
26 18 format_it_double(str_finale, formating, nb);
27 18 return str_finale;
28 }
29
30 18 int flag_f(va_list list, formating_t *formating)
31 {
32 18 double temp_nb = va_arg(list, double);
33 18 char *temp = my_get_str_float(temp_nb, formating);
34
35 18 return my_putstr_fd_free(temp, formating->fd);
36 }
37