void testIncrement() { { lunchbox::uint128_t test128( 0, 0 ); ++test128; TEST( test128.high() == 0 && test128.low() == 1 ); --test128; TEST( test128.high() == 0 && test128.low() == 0 ); test128 = test128 + 1; TEST( test128.high() == 0 && test128.low() == 1 ); test128 = test128 - 1; TEST( test128.high() == 0 && test128.low() == 0 ); } { lunchbox::uint128_t test128( 0, std::numeric_limits<uint64_t>::max() ); ++test128; TEST( test128.high() == 1 && test128.low() == 0 ); --test128; TEST( test128.high() == 0 && test128.low() == std::numeric_limits< uint64_t >::max() ); test128 = test128 + 1; TEST( test128.high() == 1 && test128.low() == 0 ); test128 = test128 - 1; TEST( test128.high() == 0 && test128.low() == std::numeric_limits< uint64_t >::max() ); } { lunchbox::uint128_t test128( 0, 0 ); ++test128; TEST( test128.high() == 0 && test128.low() == 1 ); --test128; TEST( test128.high() == 0 && test128.low() == 0 ); test128 = test128 + 1; TEST( test128.high() == 0 && test128.low() == 1 ); test128 = test128 - 1; TEST( test128.high() == 0 && test128.low() == 0 ); } { lunchbox::uint128_t test128( 0, std::numeric_limits< uint64_t >::max() ); ++test128; TEST( test128.high() == 1 && test128.low() == 0 ); --test128; TEST( test128.high() == 0 && test128.low() == std::numeric_limits< uint64_t >::max() ); test128 = test128 + 1; TEST( test128.high() == 1 && test128.low() == 0 ); test128 = test128 - 1; TEST( test128.high() == 0 && test128.low() == std::numeric_limits< uint64_t >::max() ); } }
int main(void) { int i; if (check_for_aes_instructions() == 0) { printf("no AES instructions detected! - stopping the test app\n"); return 1; } printf("AES instructions detected\n"); for (i=1;i<4096;i+=i*3/2) { printf("testing %d blocks,AES-128: %s",i,(test128(i) != TEST_PASS) ? "FAIL" : "PASS"); printf(",AES-192: %s",(test192(i) != TEST_PASS) ? "FAIL" : "PASS"); printf(",AES-256: %s",(test256(i) != TEST_PASS) ? "FAIL" : "PASS"); printf("\n"); } for (i=1;i<4096;i+=i*3/2) { printf("testing %d blocks,AES-128-CBC: %s",i,(test128_CBC(i) != TEST_PASS) ? "FAIL" : "PASS"); printf(",AES-192-CBC: %s",(test192_CBC(i) != TEST_PASS) ? "FAIL" : "PASS"); printf(",AES-256-CBC: %s\n",(test256_CBC(i) != TEST_PASS) ? "FAIL" : "PASS"); printf("\n"); } return 0; }
void testConvertUint128ToUUID() { const uint64_t low = 1212; const uint64_t high = 2314; lunchbox::uint128_t test128( high, low ); TEST( test128.low() == low && test128.high() == high ); lunchbox::uint128_t testUUID; testUUID = test128; const lunchbox::uint128_t compare128 = testUUID; TEST( compare128 == test128 ); }