GCC Code Coverage Report


Directory: ./
File: lib/my/my_str_contains.c
Date: 2024-06-05 00:36:48
Exec Total Coverage
Lines: 11 12 91.7%
Functions: 2 2 100.0%
Branches: 10 12 83.3%

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 1201753 static int check_char_list(char *str, char *char_list, int i)
17 {
18
2/2
✓ Branch 0 taken 2554070 times.
✓ Branch 1 taken 1201548 times.
3755618 for (int j = 0; char_list[j] != '\0'; j++) {
19
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 2553865 times.
2554070 if (str[i] == char_list[j])
20 205 return 1;
21 }
22 1201548 return 0;
23 }
24
25 41976 int my_str_contains(char *str, char *char_list)
26 {
27
2/4
✓ Branch 0 taken 41976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41976 times.
41976 if (str == NULL || char_list == NULL)
28 return 0;
29
2/2
✓ Branch 0 taken 1201753 times.
✓ Branch 1 taken 41771 times.
1243524 for (int i = 0; str[i] != '\0'; i++) {
30
2/2
✓ Branch 1 taken 205 times.
✓ Branch 2 taken 1201548 times.
1201753 if (check_char_list(str, char_list, i))
31 205 return 1;
32 }
33 41771 return 0;
34 }
35