GCC Code Coverage Report


Directory: ./
File: lib/my/my_showstr.c
Date: 2024-06-05 00:36:48
Exec Total Coverage
Lines: 13 13 100.0%
Functions: 2 2 100.0%
Branches: 5 6 83.3%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2023
3 ** my_showstr
4 ** File description:
5 ** Prints a string (str) but replaces
6 ** non-printable characters with their hexadecimal number
7 */
8 /**
9 * @file my_showstr.c
10 * @brief The file containing the my_showstr function
11 * @author Nicolas TORO
12 */
13
14 #include "my.h"
15
16 2 static void check_zero_in_hexadecimal(char c)
17 {
18
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (c < 16)
19 2 my_putchar('0');
20 2 }
21
22 1 void my_showstr(char const *str)
23 {
24 1 int len = my_strlen(str);
25
26
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 for (int i = 0; i < len; i++) {
27
2/2
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
7 if (my_char_is_printable(str[i]) == 1) {
28 5 my_putchar(str[i]);
29 } else {
30 2 my_putchar('\\');
31 2 check_zero_in_hexadecimal(str[i]);
32 2 my_putnbr_base(str[i], "0123456789abcedf");
33 }
34 }
35 1 }
36