alelievr / libft-unit-test

455 stars 88 forks source link

ft_strclpy #91

Closed Alienxbe closed 3 years ago

Alienxbe commented 3 years ago

Actually the function ft_strlcpy shouldn't be protected. But in your unit test it's needed.

alelievr commented 3 years ago

Are you sure about it? There is a test to prevent people from protecting it from null:

void        test_ft_strlcpy_null(void *ptr) {
    typeof(strlcpy) *ft_strlcpy = ptr;
    SET_EXPLANATION("your strlcpy doe not segfault when null parameter is sent");

    SANDBOX_PROT(
            ft_strlcpy(NULL, NULL, 10);
            );
}
reysand commented 3 years ago

I think he meant it: image

100

alelievr commented 3 years ago

Yes, I misread the issue, it should be fixed now

see7e commented 10 months ago

I know that this issue is closed but the return value of the function is an int and shouldn't return a NULL pointer as your test expects.

ft_strlcpy      : [OK] [OK] [OK] [OK] [OK] [OK] [NO CRASH] 
[no crash]: your strlcpy doe not segfault when null parameter is sent

This raise

if (!dest && !src)
        return (NULL);
✖ Executing: make fclean all bonus
ft_strlcpy.c: In function ‘ft_strlcpy’:
ft_strlcpy.c:23:10: error: returning ‘void *’ from a function with return type ‘unsigned int’ makes integer from pointer without a cast [-Werror=int-conversion]
   23 |   return (NULL);
      |          ^
cc1: all warnings being treated as errors
make: *** [<builtin>: ft_strlcpy.o] Error 1