Skip to content

Commit aab7793

Browse files
committed
acl_hash_test: test bitwise left-rotation
Signed-off-by: Peter Colberg <[email protected]>
1 parent 07778df commit aab7793

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

lib/acl_hash/test/acl_hash_test.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,40 @@ TEST(Hash, hexdigest_str129) {
177177
CHECK_EQUAL(0, strcmp(m_digest, "7bcbe82f22dcf896409dd4759fc45ea83e4c05d2"));
178178
CHECK_EQUAL(0, m_ctx.is_open);
179179
}
180+
181+
TEST_GROUP(Internal){};
182+
183+
TEST(Internal, Rotate) {
184+
CHECK_EQUAL(0x12345678, l_leftrotate(0x12345678, 0));
185+
CHECK_EQUAL(0x2468acf0, l_leftrotate(0x12345678, 1));
186+
CHECK_EQUAL(0x48d159e0, l_leftrotate(0x12345678, 2));
187+
CHECK_EQUAL(0x91a2b3c0, l_leftrotate(0x12345678, 3));
188+
CHECK_EQUAL(0x23456781, l_leftrotate(0x12345678, 4));
189+
CHECK_EQUAL(0x468acf02, l_leftrotate(0x12345678, 5));
190+
CHECK_EQUAL(0x8d159e04, l_leftrotate(0x12345678, 6));
191+
CHECK_EQUAL(0x1a2b3c09, l_leftrotate(0x12345678, 7));
192+
CHECK_EQUAL(0x34567812, l_leftrotate(0x12345678, 8));
193+
CHECK_EQUAL(0x68acf024, l_leftrotate(0x12345678, 9));
194+
CHECK_EQUAL(0xd159e048, l_leftrotate(0x12345678, 10));
195+
CHECK_EQUAL(0xa2b3c091, l_leftrotate(0x12345678, 11));
196+
CHECK_EQUAL(0x45678123, l_leftrotate(0x12345678, 12));
197+
CHECK_EQUAL(0x8acf0246, l_leftrotate(0x12345678, 13));
198+
CHECK_EQUAL(0x159e048d, l_leftrotate(0x12345678, 14));
199+
CHECK_EQUAL(0x2b3c091a, l_leftrotate(0x12345678, 15));
200+
CHECK_EQUAL(0x56781234, l_leftrotate(0x12345678, 16));
201+
CHECK_EQUAL(0xacf02468, l_leftrotate(0x12345678, 17));
202+
CHECK_EQUAL(0x59e048d1, l_leftrotate(0x12345678, 18));
203+
CHECK_EQUAL(0xb3c091a2, l_leftrotate(0x12345678, 19));
204+
CHECK_EQUAL(0x67812345, l_leftrotate(0x12345678, 20));
205+
CHECK_EQUAL(0xcf02468a, l_leftrotate(0x12345678, 21));
206+
CHECK_EQUAL(0x9e048d15, l_leftrotate(0x12345678, 22));
207+
CHECK_EQUAL(0x3c091a2b, l_leftrotate(0x12345678, 23));
208+
CHECK_EQUAL(0x78123456, l_leftrotate(0x12345678, 24));
209+
CHECK_EQUAL(0xf02468ac, l_leftrotate(0x12345678, 25));
210+
CHECK_EQUAL(0xe048d159, l_leftrotate(0x12345678, 26));
211+
CHECK_EQUAL(0xc091a2b3, l_leftrotate(0x12345678, 27));
212+
CHECK_EQUAL(0x81234567, l_leftrotate(0x12345678, 28));
213+
CHECK_EQUAL(0x02468acf, l_leftrotate(0x12345678, 29));
214+
CHECK_EQUAL(0x048d159e, l_leftrotate(0x12345678, 30));
215+
CHECK_EQUAL(0x091a2b3c, l_leftrotate(0x12345678, 31));
216+
}

0 commit comments

Comments
 (0)