GCC Code Coverage Report


Directory: ./
File: lib/my/flags/sub_format_str.c
Date: 2024-06-05 00:29:21
Exec Total Coverage
Lines: 29 29 100.0%
Functions: 6 6 100.0%
Branches: 12 14 85.7%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2023
3 ** my_printf
4 ** File description:
5 ** The functions for format a string
6 */
7
8 #include <stdarg.h>
9 #include "my.h"
10 #include "myformats.h"
11
12 2 static void do_next_str(char *str_finale,
13 formating_t *formating)
14 {
15 2 void (*format[])(char *, formating_t *) =
16 {&format_moins_str, &format_plus_str, &format_esp_str,
17 &format_hash_str, &format_zero_str};
18
19
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 for (int j = 0; j < 5; j++) {
20
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6 times.
7 if (formating->next_chara == FORMATAGE[j]) {
21 1 format[j](str_finale, formating);
22 1 return;
23 }
24 }
25 }
26
27 2 void format_plus_str(char *str_finale,
28 formating_t *formating)
29 {
30 2 format_esp_str(str_finale, formating);
31 2 return;
32 }
33
34 2 void format_moins_str(char *str_finale,
35 formating_t *formating)
36 {
37
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 if ((my_strlen(str_finale) < formating->id_wd
38
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 && formating->next_chara == '+')
39
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 || my_strlen(str_finale) < formating->id_wd) {
40
2/2
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 2 times.
12 for (int i = my_strlen(str_finale); i < formating->id_wd; i++) {
41 10 my_strcat(str_finale, " ");
42 }
43 }
44 2 do_next_str(str_finale, formating);
45 2 }
46
47 7 void format_esp_str(char *str_finale,
48 formating_t *formating)
49 {
50 7 my_revstr(str_finale);
51
2/2
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 7 times.
12 for (int i = my_strlen(str_finale); i < formating->id_wd; i++)
52 5 my_strcat(str_finale, " ");
53 7 my_revstr(str_finale);
54 7 }
55
56 1 void format_zero_str(char *str_finale,
57 formating_t *formating)
58 {
59 1 format_esp_str(str_finale, formating);
60 1 }
61
62 3 void format_hash_str(char *str_finale,
63 formating_t *formating)
64 {
65 3 format_esp_str(str_finale, formating);
66 3 return;
67 }
68