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

Function MultVerifyInt64Uint

Test/MultVerify.cpp:1324–1363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1322};
1323
1324void MultVerifyInt64Uint()
1325{
1326 size_t i;
1327
1328 for( i = 0; i < COUNTOF(int64_uint); ++i )
1329 {
1330 std::int64_t ret;
1331 if( SafeMultiply(int64_uint[i].x, int64_uint[i].y, ret) != int64_uint[i].fExpected )
1332 {
1333 //assert(false);
1334 // printf("Error in case %I64X, %I64X, expected = %s\n",
1335 // int64_uint[i].x, int64_uint[i].y, int64_uint[i].fExpected ? "true" : "false");
1336 cerr << "Error in case int64_uint: ";
1337 cerr << hex << setw(16) << setfill('0') << int64_uint[i].x << ", ";
1338 cerr << hex << setw(16) << setfill('0') << int64_uint[i].y << ", ";
1339 cerr << "expected = " << int64_uint[i].fExpected << endl;
1340 }
1341
1342 bool fSuccess = true;
1343 try
1344 {
1345 SafeInt<std::int64_t> si(int64_uint[i].x);
1346 si *= int64_uint[i].y;
1347 }
1348 catch(...)
1349 {
1350 fSuccess = false;
1351 }
1352
1353 if( fSuccess != int64_uint[i].fExpected )
1354 {
1355 // printf("Error in case int64_uint throw: %I64X, %I64X, expected = %s\n",
1356 // int64_uint[i].x, int64_uint[i].y, int64_uint[i].fExpected ? "true" : "false");
1357 cerr << "Error in case int64_uint throw: ";
1358 cerr << hex << setw(16) << setfill('0') << int64_uint[i].x << ", ";
1359 cerr << hex << setw(16) << setfill('0') << int64_uint[i].y << ", ";
1360 cerr << "expected = " << int64_uint[i].fExpected << endl;
1361 }
1362 }
1363}
1364
1365static const MultTest< std::int32_t, std::int64_t > int_int64[] =
1366{

Callers 1

MultVerifyFunction · 0.70

Calls 1

SafeMultiplyFunction · 0.50

Tested by

no test coverage detected