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

Function MultVerifyIntInt64

Archive/releases/2/MultVerify.cpp:1478–1517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1476};
1477
1478void MultVerifyIntInt64()
1479{
1480 size_t i;
1481
1482 for( i = 0; i < COUNTOF(int_int64); ++i )
1483 {
1484 __int32 ret;
1485 if( SafeMultiply(int_int64[i].x, int_int64[i].y, ret) != int_int64[i].fExpected )
1486 {
1487 //assert(false);
1488 // printf("Error in case %I64X, %I64X, expected = %s\n",
1489 // int_int64[i].x, int_int64[i].y, int_int64[i].fExpected ? "true" : "false");
1490 cerr << "Error in case int_int64: ";
1491 cerr << hex << setw(16) << setfill('0') << int_int64[i].x << ", ";
1492 cerr << hex << setw(16) << setfill('0') << int_int64[i].y << ", ";
1493 cerr << "expected = " << int_int64[i].fExpected << endl;
1494 }
1495
1496 bool fSuccess = true;
1497 try
1498 {
1499 SafeInt<signed __int32> si(int_int64[i].x);
1500 si *= int_int64[i].y;
1501 }
1502 catch(...)
1503 {
1504 fSuccess = false;
1505 }
1506
1507 if( fSuccess != int_int64[i].fExpected )
1508 {
1509 // printf("Error in case int_int64 throw: %I64X, %I64X, expected = %s\n",
1510 // int_int64[i].x, int_int64[i].y, int_int64[i].fExpected ? "true" : "false");
1511 cerr << "Error in case int_int64 throw: ";
1512 cerr << hex << setw(16) << setfill('0') << int_int64[i].x << ", ";
1513 cerr << hex << setw(16) << setfill('0') << int_int64[i].y << ", ";
1514 cerr << "expected = " << int_int64[i].fExpected << endl;
1515 }
1516 }
1517}
1518
1519static const MultTest< __int32, unsigned __int64 > int_uint64[] =
1520{

Callers 1

MultVerifyFunction · 0.70

Calls 1

SafeMultiplyFunction · 0.50

Tested by

no test coverage detected