GCC Code Coverage Report


Directory: ./
File: lib/my/my_printf/specifier_base.c
Date: 2024-06-05 00:34:38
Exec Total Coverage
Lines: 15 15 100.0%
Functions: 5 5 100.0%
Branches: 4 4 100.0%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2023
3 ** my_printf
4 ** File description:
5 ** The functions for apply an specifier on an number in different base
6 */
7 /**
8 * @file specifier_base.c
9 * @brief The file containing the specifier_base function
10 * @author Nicolas TORO
11 */
12
13 #include "myprintf.h"
14
15 8 static char *select_long_long(size_t temp, char *base)
16 {
17 8 return my_str_nbr_base_unsigned_long((long)temp, base);
18 }
19
20 4 static char *select_short(size_t temp, char *base)
21 {
22 4 return my_str_nbr_base_unsigned_short((unsigned short)temp, base);
23 }
24
25 4 static char *select_short_short(size_t temp, char *base)
26 {
27 4 return my_str_nbr_base_unsigned_short_short((unsigned char)temp, base);
28 }
29
30 4 static char *select_size_t(size_t temp, char *base)
31 {
32 4 return my_str_nbr_base_unsigned_size_t(temp, base);
33 }
34
35 77 char *specify_it_base(formating_t *formating, size_t temp, char *base)
36 {
37 77 char *(*specify[])(size_t, char *) =
38 {&select_long_long, &select_long_long,
39 &select_short, &select_short_short, &select_size_t,
40 &select_size_t, &select_size_t, &select_size_t};
41
42
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 57 times.
77 if (formating->id_sp != -1) {
43 20 return specify[formating->id_sp](temp, base);
44
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 46 times.
57 } else if (formating->flag == 'b') {
45 11 return my_convert_base_unsigned(my_str_nbr_unsigned(temp),
46 "0123456789", "01");
47 } else {
48 46 return my_str_nbr_base_unsigned((unsigned)temp, base);
49 }
50 }
51