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

Function MultVerifyInt64Uint

Archive/releases/2/MultVerify.cpp:1365–1404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1363};
1364
1365void MultVerifyInt64Uint()
1366{
1367 size_t i;
1368
1369 for( i = 0; i < COUNTOF(int64_uint); ++i )
1370 {
1371 __int64 ret;
1372 if( SafeMultiply(int64_uint[i].x, int64_uint[i].y, ret) != int64_uint[i].fExpected )
1373 {
1374 //assert(false);
1375 // printf("Error in case %I64X, %I64X, expected = %s\n",
1376 // int64_uint[i].x, int64_uint[i].y, int64_uint[i].fExpected ? "true" : "false");
1377 cerr << "Error in case int64_uint: ";
1378 cerr << hex << setw(16) << setfill('0') << int64_uint[i].x << ", ";
1379 cerr << hex << setw(16) << setfill('0') << int64_uint[i].y << ", ";
1380 cerr << "expected = " << int64_uint[i].fExpected << endl;
1381 }
1382
1383 bool fSuccess = true;
1384 try
1385 {
1386 SafeInt<signed __int64> si(int64_uint[i].x);
1387 si *= int64_uint[i].y;
1388 }
1389 catch(...)
1390 {
1391 fSuccess = false;
1392 }
1393
1394 if( fSuccess != int64_uint[i].fExpected )
1395 {
1396 // printf("Error in case int64_uint throw: %I64X, %I64X, expected = %s\n",
1397 // int64_uint[i].x, int64_uint[i].y, int64_uint[i].fExpected ? "true" : "false");
1398 cerr << "Error in case int64_uint throw: ";
1399 cerr << hex << setw(16) << setfill('0') << int64_uint[i].x << ", ";
1400 cerr << hex << setw(16) << setfill('0') << int64_uint[i].y << ", ";
1401 cerr << "expected = " << int64_uint[i].fExpected << endl;
1402 }
1403 }
1404}
1405
1406static const MultTest< __int32, __int64 > int_int64[] =
1407{

Callers 1

MultVerifyFunction · 0.70

Calls 1

SafeMultiplyFunction · 0.50

Tested by

no test coverage detected