GCC Code Coverage Report


Directory: ./
File: lib/my/my_printf/get_format.c
Date: 2024-06-05 00:36:48
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 22319 void format_first(user_t *user, flags_t *flags,
25 formating_t *formating, int *copy)
26 {
27
2/2
✓ Branch 0 taken 1990705 times.
✓ Branch 1 taken 22280 times.
2012985 for (; user->str[*copy - 1] != flags->str[flags->index_flag]; (*copy)++) {
28 1990705 find_first(user, copy, formating);
29
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 1990666 times.
1990705 if (formating->id_ft != -1) {
30 39 check_operator(formating);
31 39 break;
32 }
33 }
34 22319 }
35
36 22319 void format_width(user_t *user, flags_t *flags,
37 formating_t *formating, int *copy)
38 {
39
2/2
✓ Branch 0 taken 1995006 times.
✓ Branch 1 taken 22285 times.
2017291 for (; user->str[*copy - 1] != flags->str[flags->index_flag]; (*copy)++) {
40 1995006 find_width(user, copy, formating);
41
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 1994972 times.
1995006 if (formating->id_wd != -1) {
42 34 (formating->nb_format) += my_strlen(my_str_nbr(formating->id_wd));
43 34 break;
44 }
45 }
46 22319 }
47
48 22319 void format_precision(user_t *user, flags_t *flags,
49 formating_t *formating, int *copy)
50 {
51
2/2
✓ Branch 0 taken 1982071 times.
✓ Branch 1 taken 22292 times.
2004363 for (; user->str[*copy - 1] != flags->str[flags->index_flag]; (*copy)++) {
52 1982071 find_precision(user, copy, formating);
53
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1982044 times.
1982071 if (formating->id_prc != -1) {
54 27 formating->nb_format += 1;
55 27 break;
56 }
57 }
58 22319 }
59
60 22319 void format_numbers(user_t *user, flags_t *flags,
61 formating_t *formating, int *copy)
62 {
63
2/2
✓ Branch 0 taken 1981902 times.
✓ Branch 1 taken 22290 times.
2004192 for (; user->str[*copy - 1] != flags->str[flags->index_flag]; (*copy)++) {
64 1981902 find_numbers(user, copy, formating);
65
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1981873 times.
1981902 if (formating->id_nb != -1) {
66 29 (formating->nb_format) += my_strlen(my_str_nbr(formating->id_nb));
67 29 break;
68 }
69 }
70 22319 }
71
72 22319 void format_specifier(user_t *user, flags_t *flags,
73 formating_t *formating, int *copy)
74 {
75 22319 find_specifier(user, copy, formating);
76
4/4
✓ Branch 0 taken 22308 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 22299 times.
22319 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 22271 times.
22299 } else if (formating->id_sp != - 1) {
79 28 formating->nb_format += 1;
80 }
81 22319 }
82