GCC Code Coverage Report


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

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2024
3 ** my_str_contains
4 ** File description:
5 ** Returns 1 if the string (str) contains at least one character from the
6 ** char list (char_list), 0 otherwise
7 */
8 /**
9 * @file my_str_contains.c
10 * @brief The file containing the my_str_contains function
11 * @author Nicolas TORO
12 */
13
14 #include "my.h"
15
16 7 static int check_char_list(char *str, char *char_list, int i)
17 {
18
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6 times.
13 for (int j = 0; char_list[j] != '\0'; j++) {
19
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6 times.
7 if (str[i] == char_list[j])
20 1 return 1;
21 }
22 6 return 0;
23 }
24
25 4 int my_str_contains(char *str, char *char_list)
26 {
27
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
4 if (str == NULL || char_list == NULL)
28 2 return 0;
29
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 for (int i = 0; str[i] != '\0'; i++) {
30
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 6 times.
7 if (check_char_list(str, char_list, i))
31 1 return 1;
32 }
33 1 return 0;
34 }
35