GCC Code Coverage Report


Directory: ./
File: lib/my/my_printf/sub_format_str.c
Date: 2024-06-05 00:36:48
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 * @file sub_format_str.c
9 * @brief The file containing the sub_format_str functions
10 * @author Nicolas TORO
11 */
12
13 #include "myprintf.h"
14
15 2 static void do_next_str(char *str_finale,
16 formating_t *formating)
17 {
18 2 void (*format[])(char *, formating_t *) =
19 {&format_moins_str, &format_plus_str, &format_esp_str,
20 &format_hash_str, &format_zero_str};
21
22
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 for (int j = 0; j < 5; j++) {
23
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6 times.
7 if (formating->next_chara == FORMATAGE[j]) {
24 1 format[j](str_finale, formating);
25 1 return;
26 }
27 }
28 }
29
30 2 void format_plus_str(char *str_finale,
31 formating_t *formating)
32 {
33 2 format_esp_str(str_finale, formating);
34 2 return;
35 }
36
37 2 void format_moins_str(char *str_finale,
38 formating_t *formating)
39 {
40
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 if ((my_strlen(str_finale) < formating->id_wd
41
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 && formating->next_chara == '+')
42
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 || my_strlen(str_finale) < formating->id_wd) {
43
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++) {
44 10 my_strcat(str_finale, " ");
45 }
46 }
47 2 do_next_str(str_finale, formating);
48 2 }
49
50 7 void format_esp_str(char *str_finale,
51 formating_t *formating)
52 {
53 7 my_revstr(str_finale);
54
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++)
55 5 my_strcat(str_finale, " ");
56 7 my_revstr(str_finale);
57 7 }
58
59 1 void format_zero_str(char *str_finale,
60 formating_t *formating)
61 {
62 1 format_esp_str(str_finale, formating);
63 1 }
64
65 3 void format_hash_str(char *str_finale,
66 formating_t *formating)
67 {
68 3 format_esp_str(str_finale, formating);
69 3 return;
70 }
71