GCC Code Coverage Report


Directory: ./
File: lib/my/my_strstr.c
Date: 2024-06-05 00:29:21
Exec Total Coverage
Lines: 7 7 100.0%
Functions: 1 1 100.0%
Branches: 6 6 100.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 occurence
7 */
8
9 #include <stddef.h>
10 #include "my.h"
11
12 3 char *my_strstr(char *str, char const *to_find)
13 {
14
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
3 if (my_strlen(to_find) == 0)
15 1 return str;
16
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 for (int i = 0; str[i] != '\0'; i++) {
17
2/2
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 6 times.
7 if (my_strncmp(&str[i], to_find, my_strlen(to_find)) == 0) {
18 1 return &str[i];
19 }
20 }
21 1 return NULL;
22 }
23