GCC Code Coverage Report


Directory: ./
File: lib/my/my_strncpy.c
Date: 2024-06-05 00:29:21
Exec Total Coverage
Lines: 8 9 88.9%
Functions: 1 1 100.0%
Branches: 5 6 83.3%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2023
3 ** my_strncpy
4 ** File description:
5 ** Copy a string (src) and paste it on another string (dest)
6 ** with a defined size (n)
7 */
8
9 1 char *my_strncpy(char *dest, char const *src, int n)
10 {
11 1 int len = 0;
12
13
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 while (src[len] != '\0') {
14 6 len = len + 1;
15 }
16
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for (int i = 0; i < n; i++) {
17 5 dest[i] = src[i];
18 }
19
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (len < n) {
20 dest[len] = '\0';
21 }
22 1 return dest;
23 }
24