GCC Code Coverage Report


Directory: ./
File: lib/my/my_strstr.c
Date: 2024-06-05 00:36:48
Exec Total Coverage
Lines: 8 9 88.9%
Functions: 1 1 100.0%
Branches: 8 10 80.0%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2023
3 ** my_strstr
4 ** File description:
5 ** Search a string (to_find) on another (str)
6 ** and returns the address of the first occurrence
7 */
8 /**
9 * @file my_strstr.c
10 * @brief The file containing the my_strstr function
11 * @author Nicolas TORO
12 */
13
14 #include "my.h"
15
16 10234 char *my_strstr(char *str, char const *to_find)
17 {
18
2/4
✓ Branch 0 taken 10234 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10234 times.
10234 if (str == NULL || to_find == NULL)
19 return NULL;
20
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 10233 times.
10234 if (my_strlen(to_find) == 0)
21 1 return str;
22
2/2
✓ Branch 0 taken 531708 times.
✓ Branch 1 taken 9424 times.
541132 for (int i = 0; str[i] != '\0'; i++) {
23
2/2
✓ Branch 2 taken 809 times.
✓ Branch 3 taken 530899 times.
531708 if (my_strncmp(&str[i], to_find, my_strlen(to_find)) == 0)
24 809 return &str[i];
25 }
26 9424 return NULL;
27 }
28