GCC Code Coverage Report


Directory: ./
File: lib/my/my_str_nbr_size_t.c
Date: 2024-06-05 00:34:38
Exec Total Coverage
Lines: 16 16 100.0%
Functions: 2 2 100.0%
Branches: 4 4 100.0%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2023
3 ** my_str_nbr_size_t
4 ** File description:
5 ** Returns the string conversion of a big unsigned number (nb)
6 */
7 /**
8 * @file my_str_nbr_size_t.c
9 * @brief The file containing the my_str_nbr_size_t function
10 * @author Nicolas TORO
11 */
12
13 #include "my.h"
14
15 31 static char *set_str_nb(size_t nb, int int_nb)
16 {
17 31 char *nb_str = malloc(sizeof(char) * (int_nb + 1));
18 31 int j = 0;
19 31 size_t figure_temp = nb;
20
21
2/2
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 31 times.
509 for (j = 0; j < int_nb; j++) {
22 478 nb_str[j] = 48 + (figure_temp % 10);
23 478 figure_temp = (figure_temp - (figure_temp % 10)) / 10;
24 }
25 31 nb_str[j] = '\0';
26 31 return my_revstr(nb_str);
27 }
28
29 31 char *my_str_nbr_size_t(size_t nb)
30 {
31 31 int int_nb = 1;
32 31 size_t temp_nb = nb;
33
34
2/2
✓ Branch 0 taken 447 times.
✓ Branch 1 taken 31 times.
478 while ((temp_nb / 10) != 0) {
35 447 int_nb = int_nb + 1;
36 447 temp_nb = temp_nb / 10;
37 }
38 31 return set_str_nb(nb, int_nb);
39 }
40