Mercurial > hg > octave-lyh > gnulib-hg
changeset 10409:f0b817243938
bitrotate: Test 8/16-bit rotates with 0 and maximum rotate amounts.
author | Simon Josefsson <simon@josefsson.org> |
---|---|
date | Mon, 08 Sep 2008 12:18:02 +0200 |
parents | b59f0c45c546 |
children | ad3484c9aa0c |
files | ChangeLog tests/test-bitrotate.c |
diffstat | 2 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2008-09-08 Simon Josefsson <simon@josefsson.org> + * tests/test-bitrotate.c: Test 8/16-bit rotates with 0 and maximum + rotate amounts. + * lib/bitrotate.h: Doc fix, mention that N can be wider than minimally required for 16-bit and 8-bit rotates. * lib/bitrotate.h (rotl64, rotr64, rotl32, rotl32, rotl16, rotr16,
--- a/tests/test-bitrotate.c +++ b/tests/test-bitrotate.c @@ -39,6 +39,7 @@ int main (void) { + ASSERT (rotl8 (42, 0) == 42); ASSERT (rotl8 (42, 1) == 84); ASSERT (rotl8 (42, 2) == 168); ASSERT (rotl8 (42, 3) == 81); @@ -46,7 +47,9 @@ ASSERT (rotl8 (42, 5) == 69); ASSERT (rotl8 (42, 6) == 138); ASSERT (rotl8 (42, 7) == 21); + ASSERT (rotl8 (42, 8) == 42); + ASSERT (rotr8 (42, 0) == 42); ASSERT (rotr8 (42, 1) == 21); ASSERT (rotr8 (42, 2) == 138); ASSERT (rotr8 (42, 3) == 69); @@ -54,7 +57,9 @@ ASSERT (rotr8 (42, 5) == 81); ASSERT (rotr8 (42, 6) == 168); ASSERT (rotr8 (42, 7) == 84); + ASSERT (rotr8 (42, 8) == 42); + ASSERT (rotl16 (43981, 0) == 43981); ASSERT (rotl16 (43981, 1) == 22427); ASSERT (rotl16 (43981, 2) == 44854); ASSERT (rotl16 (43981, 3) == 24173); @@ -70,7 +75,9 @@ ASSERT (rotl16 (43981, 13) == 46457); ASSERT (rotl16 (43981, 14) == 27379); ASSERT (rotl16 (43981, 15) == 54758); + ASSERT (rotl16 (43981, 16) == 43981); + ASSERT (rotr16 (43981, 0) == 43981); ASSERT (rotr16 (43981, 1) == 54758); ASSERT (rotr16 (43981, 2) == 27379); ASSERT (rotr16 (43981, 3) == 46457); @@ -86,6 +93,7 @@ ASSERT (rotr16 (43981, 13) == 24173); ASSERT (rotr16 (43981, 14) == 44854); ASSERT (rotr16 (43981, 15) == 22427); + ASSERT (rotr16 (43981, 16) == 43981); ASSERT (rotl32 (2309737967U, 1) == 324508639U); ASSERT (rotl32 (2309737967U, 2) == 649017278U);