GCC Code Coverage Report


Directory: ./
File: lib/my/my_printf/get_format.c
Date: 2024-05-07 14:54:03
Exec Total Coverage
Lines: 40 40 100.0%
Functions: 6 6 100.0%
Branches: 26 26 100.0%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2023
3 ** my_printf
4 ** File description:
5 ** The functions for get the format
6 */
7 /**
8 * @file get_format.c
9 * @brief The file containing the get_format function
10 * @author Nicolas TORO
11 */
12
13 #include "myprintf.h"
14
15 39 static void check_operator(formating_t *formating)
16 {
17
4/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 30 times.
39 if (formating->next_chara == '+' || formating->next_chara == '-') {
18 9 formating->nb_format += 2;
19 } else {
20 30 (formating->nb_format) += 1;
21 }
22 39 }
23
24 26081 void format_first(user_t *user, flags_t *flags,
25 formating_t *formating, int *copy)
26 {
27
2/2
✓ Branch 0 taken 2491440 times.
✓ Branch 1 taken 26042 times.
2517482 for (; user->str[*copy - 1] != flags->str[flags->index_flag]; (*copy)++) {
28 2491440 find_first(user, copy, formating);
29
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 2491401 times.
2491440 if (formating->id_ft != -1) {
30 39 check_operator(formating);
31 39 break;
32 }
33 }
34 26081 }
35
36 26081 void format_width(user_t *user, flags_t *flags,
37 formating_t *formating, int *copy)
38 {
39
2/2
✓ Branch 0 taken 2495741 times.
✓ Branch 1 taken 26047 times.
2521788 for (; user->str[*copy - 1] != flags->str[flags->index_flag]; (*copy)++) {
40 2495741 find_width(user, copy, formating);
41
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2495707 times.
2495741 if (formating->id_wd != -1) {
42 34 (formating->nb_format) += my_strlen(my_str_nbr(formating->id_wd));
43 34 break;
44 }
45 }
46 26081 }
47
48 26081 void format_precision(user_t *user, flags_t *flags,
49 formating_t *formating, int *copy)
50 {
51
2/2
✓ Branch 0 taken 2482694 times.
✓ Branch 1 taken 26054 times.
2508748 for (; user->str[*copy - 1] != flags->str[flags->index_flag]; (*copy)++) {
52 2482694 find_precision(user, copy, formating);
53
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2482667 times.
2482694 if (formating->id_prc != -1) {
54 27 formating->nb_format += 1;
55 27 break;
56 }
57 }
58 26081 }
59
60 26081 void format_numbers(user_t *user, flags_t *flags,
61 formating_t *formating, int *copy)
62 {
63
2/2
✓ Branch 0 taken 2482525 times.
✓ Branch 1 taken 26052 times.
2508577 for (; user->str[*copy - 1] != flags->str[flags->index_flag]; (*copy)++) {
64 2482525 find_numbers(user, copy, formating);
65
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 2482496 times.
2482525 if (formating->id_nb != -1) {
66 29 (formating->nb_format) += my_strlen(my_str_nbr(formating->id_nb));
67 29 break;
68 }
69 }
70 26081 }
71
72 26081 void format_specifier(user_t *user, flags_t *flags,
73 formating_t *formating, int *copy)
74 {
75 26081 find_specifier(user, copy, formating);
76
4/4
✓ Branch 0 taken 26070 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 26061 times.
26081 if (formating->id_sp == 1 || formating->id_sp == 3) {
77 20 formating->nb_format += 2;
78
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 26033 times.
26061 } else if (formating->id_sp != - 1) {
79 28 formating->nb_format += 1;
80 }
81 26081 }
82