alelievr / libft-unit-test

453 stars 88 forks source link

memcpy: test for one NULL param and size 0. #142

Closed ghost closed 1 year ago

ghost commented 1 year ago

A "typical" memcpy will not crash (because of the zero size).

Even though this is, AFAICT, actually undefined behavior, Lausanne's moulinette appears to do a similar test, so it's probably a good idea to consider it an error in a libft tester as well.

Some students cannot figure out how/why memcpy crashes "naturally" and come up with creative ways to do it forcibly instead; but as a result their ft_memcpy may crash even in cases where a "typical" implementation of memcpy wouldn't. This catches some of them.

Example failing implementation of memcpy: https://gist.github.com/Rodeo314/c4a52a902acf60336203c90f04b9a31d