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

Function MultVerifyInt64Int

Test/MultVerify.cpp:1213–1252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1211};
1212
1213void MultVerifyInt64Int()
1214{
1215 size_t i;
1216
1217 for( i = 0; i < COUNTOF(int64_int); ++i )
1218 {
1219 std::int64_t ret;
1220 if( SafeMultiply(int64_int[i].x, int64_int[i].y, ret) != int64_int[i].fExpected )
1221 {
1222 //assert(false);
1223 // printf("Error in case %I64X, %I64X, expected = %s\n",
1224 // int64_int[i].x, int64_int[i].y, int64_int[i].fExpected ? "true" : "false");
1225 cerr << "Error in case int64_int: ";
1226 cerr << hex << setw(16) << setfill('0') << int64_int[i].x << ", ";
1227 cerr << hex << setw(16) << setfill('0') << int64_int[i].y << ", ";
1228 cerr << "expected = " << int64_int[i].fExpected << endl;
1229 }
1230
1231 bool fSuccess = true;
1232 try
1233 {
1234 SafeInt<std::int64_t> si(int64_int[i].x);
1235 si *= int64_int[i].y;
1236 }
1237 catch(...)
1238 {
1239 fSuccess = false;
1240 }
1241
1242 if( fSuccess != int64_int[i].fExpected )
1243 {
1244 // printf("Error in case int64_int throw: %I64X, %I64X, expected = %s\n",
1245 // int64_int[i].x, int64_int[i].y, int64_int[i].fExpected ? "true" : "false");
1246 cerr << "Error in case int64_int throw: ";
1247 cerr << hex << setw(16) << setfill('0') << int64_int[i].x << ", ";
1248 cerr << hex << setw(16) << setfill('0') << int64_int[i].y << ", ";
1249 cerr << "expected = " << int64_int[i].fExpected << endl;
1250 }
1251 }
1252}
1253
1254static const MultTest< std::int64_t, std::uint32_t > int64_uint[] =
1255{

Callers 1

MultVerifyFunction · 0.70

Calls 1

SafeMultiplyFunction · 0.50

Tested by

no test coverage detected