GCC Code Coverage Report


Directory: ./
File: lib/my/my_str_nbr_unsigned.c
Date: 2024-06-05 00:36:48
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_unsigned
4 ** File description:
5 ** Returns the string conversion of an unsigned number (nb)
6 */
7 /**
8 * @file my_str_nbr_unsigned.c
9 * @brief The file containing the my_str_nbr_unsigned function
10 * @author Nicolas TORO
11 */
12
13 #include "my.h"
14
15 12 static char *set_str_nb(int nb, int int_nb)
16 {
17 12 char *nb_str = malloc(sizeof(char) * (int_nb + 1));
18 12 int j = 0;
19 12 unsigned int figure_temp = nb;
20
21
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 12 times.
49 for (j = 0; j < int_nb; j++) {
22 37 nb_str[j] = 48 + (figure_temp % 10);
23 37 figure_temp = (figure_temp - (figure_temp % 10)) / 10;
24 }
25 12 nb_str[j] = '\0';
26 12 return my_revstr(nb_str);
27 }
28
29 12 char *my_str_nbr_unsigned(unsigned int nb)
30 {
31 12 int int_nb = 1;
32 12 unsigned int temp_nb = nb;
33
34
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 12 times.
37 while ((temp_nb / 10) != 0) {
35 25 int_nb = int_nb + 1;
36 25 temp_nb = temp_nb / 10;
37 }
38 12 return set_str_nb(nb, int_nb);
39 }
40