MCPcopy Create free account
hub / github.com/dcleblanc/SafeInt / MultVerifyIntInt64

Function MultVerifyIntInt64

Test/MultVerify.cpp:1437–1476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1435};
1436
1437void MultVerifyIntInt64()
1438{
1439 size_t i;
1440
1441 for( i = 0; i < COUNTOF(int_int64); ++i )
1442 {
1443 std::int32_t ret;
1444 if( SafeMultiply(int_int64[i].x, int_int64[i].y, ret) != int_int64[i].fExpected )
1445 {
1446 //assert(false);
1447 // printf("Error in case %I64X, %I64X, expected = %s\n",
1448 // int_int64[i].x, int_int64[i].y, int_int64[i].fExpected ? "true" : "false");
1449 cerr << "Error in case int_int64: ";
1450 cerr << hex << setw(16) << setfill('0') << int_int64[i].x << ", ";
1451 cerr << hex << setw(16) << setfill('0') << int_int64[i].y << ", ";
1452 cerr << "expected = " << int_int64[i].fExpected << endl;
1453 }
1454
1455 bool fSuccess = true;
1456 try
1457 {
1458 SafeInt<std::int32_t> si(int_int64[i].x);
1459 si *= int_int64[i].y;
1460 }
1461 catch(...)
1462 {
1463 fSuccess = false;
1464 }
1465
1466 if( fSuccess != int_int64[i].fExpected )
1467 {
1468 // printf("Error in case int_int64 throw: %I64X, %I64X, expected = %s\n",
1469 // int_int64[i].x, int_int64[i].y, int_int64[i].fExpected ? "true" : "false");
1470 cerr << "Error in case int_int64 throw: ";
1471 cerr << hex << setw(16) << setfill('0') << int_int64[i].x << ", ";
1472 cerr << hex << setw(16) << setfill('0') << int_int64[i].y << ", ";
1473 cerr << "expected = " << int_int64[i].fExpected << endl;
1474 }
1475 }
1476}
1477
1478static const MultTest< std::int32_t, std::uint64_t > int_uint64[] =
1479{

Callers 1

MultVerifyFunction · 0.70

Calls 1

SafeMultiplyFunction · 0.50

Tested by

no test coverage detected