alelievr / libft-unit-test

455 stars 88 forks source link

added some new tests for ft_memcpy and ft_memmove (double NULL) #58

Closed ch3rrydrunk closed 5 years ago

ch3rrydrunk commented 5 years ago

Cases ignored by moulinette, but popular among tedious peers.

The behaviour of ft_functions may often be different with original memcpy and memmove. BSD versions have (dst == src) -> return rule implemented, therefore they would not segfault on getting double NULL as first 2 parameters.

e.g. Original functions would return NULL on such input: ft_memcpy(NULL, NULL, 0)

The proposed tests check this behaviour. P.S. Yes, I had to resubmit due to peer pressure on that, lol :)

alelievr commented 5 years ago

Thanks for your contribution ! For this test i would argue that since this behaviour is not defined in the documentation of BSD/POSIX implementations of memmove, it is then an implementation specific undefined behaviour. Testing for undefined behaviour may be questionable but in this case i think it is a good practice to check (src == dst) before doing unnecessary work so i'll your PR :)

ch3rrydrunk commented 5 years ago

Cheers man! btw, seen your work - FUTURE is awsm :) Big ups!

alelievr commented 5 years ago

Thanks, it's cool that you found it ^^ Still sad that the event got canceled last year :(

alelievr commented 5 years ago

You used SANDBOX_IRAISE that result in a success if the functions crashes, i think it would rather be SANDBOX_RAISE that result in a success if the function does not crash

alelievr commented 5 years ago

Fixed in https://github.com/alelievr/libft-unit-test/commit/99e99d5e5d317b0d897afa1cc12f4c664f380673