GCC Code Coverage Report


Directory: ./
File: lib/my/my_printf/get_format.c
Date: 2024-06-05 02:24:39
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 228 void format_first(user_t *user, flags_t *flags,
25 formating_t *formating, int *copy)
26 {
27
2/2
✓ Branch 0 taken 109414 times.
✓ Branch 1 taken 189 times.
109603 for (; user->str[*copy - 1] != flags->str[flags->index_flag]; (*copy)++) {
28 109414 find_first(user, copy, formating);
29
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 109375 times.
109414 if (formating->id_ft != -1) {
30 39 check_operator(formating);
31 39 break;
32 }
33 }
34 228 }
35
36 228 void format_width(user_t *user, flags_t *flags,
37 formating_t *formating, int *copy)
38 {
39
2/2
✓ Branch 0 taken 113715 times.
✓ Branch 1 taken 194 times.
113909 for (; user->str[*copy - 1] != flags->str[flags->index_flag]; (*copy)++) {
40 113715 find_width(user, copy, formating);
41
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 113681 times.
113715 if (formating->id_wd != -1) {
42 34 (formating->nb_format) += my_strlen(my_str_nbr(formating->id_wd));
43 34 break;
44 }
45 }
46 228 }
47
48 228 void format_precision(user_t *user, flags_t *flags,
49 formating_t *formating, int *copy)
50 {
51
2/2
✓ Branch 0 taken 101292 times.
✓ Branch 1 taken 201 times.
101493 for (; user->str[*copy - 1] != flags->str[flags->index_flag]; (*copy)++) {
52 101292 find_precision(user, copy, formating);
53
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 101265 times.
101292 if (formating->id_prc != -1) {
54 27 formating->nb_format += 1;
55 27 break;
56 }
57 }
58 228 }
59
60 228 void format_numbers(user_t *user, flags_t *flags,
61 formating_t *formating, int *copy)
62 {
63
2/2
✓ Branch 0 taken 101123 times.
✓ Branch 1 taken 199 times.
101322 for (; user->str[*copy - 1] != flags->str[flags->index_flag]; (*copy)++) {
64 101123 find_numbers(user, copy, formating);
65
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 101094 times.
101123 if (formating->id_nb != -1) {
66 29 (formating->nb_format) += my_strlen(my_str_nbr(formating->id_nb));
67 29 break;
68 }
69 }
70 228 }
71
72 228 void format_specifier(user_t *user, flags_t *flags,
73 formating_t *formating, int *copy)
74 {
75 228 find_specifier(user, copy, formating);
76
4/4
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 220 times.
228 if (formating->id_sp == 1 || formating->id_sp == 3) {
77 8 formating->nb_format += 2;
78
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 207 times.
220 } else if (formating->id_sp != - 1) {
79 13 formating->nb_format += 1;
80 }
81 228 }
82