GCC Code Coverage Report


Directory: ./
File: lib/my/my_strncpy.c
Date: 2024-06-05 00:36:48
Exec Total Coverage
Lines: 7 7 100.0%
Functions: 1 1 100.0%
Branches: 4 4 100.0%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2023
3 ** my_strncpy
4 ** File description:
5 ** Copies a string (src) and paste it on another string (dest)
6 ** with a defined size (n)
7 */
8 /**
9 * @file my_strncpy.c
10 * @brief The file containing the my_strncpy function
11 * @author Nicolas TORO
12 */
13
14 #include "my.h"
15
16 28 char *my_strncpy(char *dest, char const *src, int n)
17 {
18 28 int len = my_strlen(src);
19
20
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 28 times.
156 for (int i = 0; i < n; i++) {
21 128 dest[i] = src[i];
22 }
23
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 27 times.
28 if (len < n) {
24 1 dest[len] = '\0';
25 }
26 28 return dest;
27 }
28