bitrotate: Test 8/16-bit rotates with 0 and maximum rotate amounts.
authorSimon Josefsson <simon@josefsson.org>
Mon, 8 Sep 2008 10:18:02 +0000 (12:18 +0200)
committerSimon Josefsson <simon@josefsson.org>
Mon, 8 Sep 2008 10:18:02 +0000 (12:18 +0200)
ChangeLog
tests/test-bitrotate.c

index 47bc08f..0fc0019 100644 (file)
--- 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,
index 5b7d171..5ebf60f 100644 (file)
@@ -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 @@ main (void)
   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 @@ main (void)
   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 @@ main (void)
   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 @@ main (void)
   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);