GCC Code Coverage Report


Directory: ./
File: lib/my/my_strstr.c
Date: 2024-05-07 14:54:03
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 6289 char *my_strstr(char *str, char const *to_find)
17 {
18
2/4
✓ Branch 0 taken 6289 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6289 times.
6289 if (str == NULL || to_find == NULL)
19 return NULL;
20
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 6288 times.
6289 if (my_strlen(to_find) == 0)
21 1 return str;
22
2/2
✓ Branch 0 taken 133250 times.
✓ Branch 1 taken 5256 times.
138506 for (int i = 0; str[i] != '\0'; i++) {
23
2/2
✓ Branch 2 taken 1032 times.
✓ Branch 3 taken 132218 times.
133250 if (my_strncmp(&str[i], to_find, my_strlen(to_find)) == 0)
24 1032 return &str[i];
25 }
26 5256 return NULL;
27 }
28