alelievr / libft-unit-test

453 stars 88 forks source link

isalnum, tolower, toupper, calloc different behavior on Linux #115

Open m0d1nst4ll3r opened 2 years ago

m0d1nst4ll3r commented 2 years ago

isalnum returns 8 (instead of 0) on 262, 266, 272, 274, 280 etc... for some reason and since tests include non-unsigned char values, they fail when it shouldn't matter and there's no way to get it right

The same happens for tolower and toupper. Toupper returns the int cast as unsigned char for int values between -128 and -2 (yes, -1 is excluded, it returns -1). Unlike isalnum, it's possible to OK it with a simple condition, but it makes no sense catering to this odd behavior.

As for calloc, I haven't gone through it entirely yet, but the manual is different on linux and mac. The linux manual claims calloc protects against 0 values and size_t overflows whereas the mac manual claims nothing like this.

stankudrow commented 2 years ago

Waiting for merging or declining this pull request https://github.com/alelievr/libft-unit-test/pull/111 concerning ft_is* functions. On ft_calloc function: could you possibly provide some screenshots illustrating your point?

m0d1nst4ll3r commented 2 years ago

For calloc, the linux manual says: If nmemb or size is 0, then calloc() returns either NULL, or a unique pointer value that can later be successfully passed to free() The tester counts NULL returns (in case of 0) as a fail. I'm not sure the moulinette will fail this behavior. Maybe a yellow KO?

The manual also says: If the multiplication of nmemb and size would result in integer overflow, then calloc() returns an error The mac manual doesn't, however, so it's unclear what the moulinette tests and what the correct behavior should be.

github-actions[bot] commented 1 year ago

Hello! Thanks for contributing to the libft unit test.

Note that this repository is not maintained by the owner anymore, instead there is a bot that will automatically merge any reviewed pull requests. If you feel like it, here are some links that can help you submiting a change in the code base::