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

Function MultVerifyInt64Int

Archive/releases/2/MultVerify.cpp:1254–1293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1252};
1253
1254void MultVerifyInt64Int()
1255{
1256 size_t i;
1257
1258 for( i = 0; i < COUNTOF(int64_int); ++i )
1259 {
1260 __int64 ret;
1261 if( SafeMultiply(int64_int[i].x, int64_int[i].y, ret) != int64_int[i].fExpected )
1262 {
1263 //assert(false);
1264 // printf("Error in case %I64X, %I64X, expected = %s\n",
1265 // int64_int[i].x, int64_int[i].y, int64_int[i].fExpected ? "true" : "false");
1266 cerr << "Error in case int64_int: ";
1267 cerr << hex << setw(16) << setfill('0') << int64_int[i].x << ", ";
1268 cerr << hex << setw(16) << setfill('0') << int64_int[i].y << ", ";
1269 cerr << "expected = " << int64_int[i].fExpected << endl;
1270 }
1271
1272 bool fSuccess = true;
1273 try
1274 {
1275 SafeInt<signed __int64> si(int64_int[i].x);
1276 si *= int64_int[i].y;
1277 }
1278 catch(...)
1279 {
1280 fSuccess = false;
1281 }
1282
1283 if( fSuccess != int64_int[i].fExpected )
1284 {
1285 // printf("Error in case int64_int throw: %I64X, %I64X, expected = %s\n",
1286 // int64_int[i].x, int64_int[i].y, int64_int[i].fExpected ? "true" : "false");
1287 cerr << "Error in case int64_int throw: ";
1288 cerr << hex << setw(16) << setfill('0') << int64_int[i].x << ", ";
1289 cerr << hex << setw(16) << setfill('0') << int64_int[i].y << ", ";
1290 cerr << "expected = " << int64_int[i].fExpected << endl;
1291 }
1292 }
1293}
1294
1295static const MultTest< __int64, unsigned __int32 > int64_uint[] =
1296{

Callers 1

MultVerifyFunction · 0.70

Calls 1

SafeMultiplyFunction · 0.50

Tested by

no test coverage detected