Re: [PATCH v4] lib/math: Add int_sqrt test suite

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux