On Tue, 10 Dec 2024, Luis Felipe Hernandez wrote:

> Adds test suite for integer based square root function.
> 
> +struct test_case_params {
> +     unsigned long x;
> +     unsigned long expected_result;
> +     const char *name;
> +};
> +
> +static const struct test_case_params params[] = {
> +     { 0, 0, "edge-case: square root of 0" },
> +     { 4, 2, "perfect square: square root of 4" },
> +     { 81, 9, "perfect square: square root of 9" },
> +     { 2, 1, "non-perfect square: square root of 2" },
> +     { 5, 2, "non-perfect square: square root of 5"},
> +     { ULONG_MAX, 4294967295, "large input"},

This will fail on a 32-bit system where sizeof(long) == 32 and 
ULONG_MAX == 4294967295. (meaning the result would be 65535).


Nicolas

Reply via email to