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

Function MultVerifyInt64Int

Archive/releases/4/MulTest.cpp:1173–1202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1171};
1172
1173void MultVerifyInt64Int()
1174{
1175 size_t i;
1176
1177 for( i = 0; i < sizeof(int64_int)/sizeof(int64_int[0]); ++i )
1178 {
1179 __int64 ret;
1180 if( SafeMultiply(int64_int[i].x, int64_int[i].y, ret) != int64_int[i].fExpected )
1181 {
1182 //assert(false);
1183 printf("Error in case %I64X, %I64X, expected = %s\n", int64_int[i].x, int64_int[i].y, int64_int[i].fExpected ? "true" : "false");
1184 }
1185
1186 bool fSuccess = true;
1187 try
1188 {
1189 SafeInt<signed __int64> si(int64_int[i].x);
1190 si *= int64_int[i].y;
1191 }
1192 catch(...)
1193 {
1194 fSuccess = false;
1195 }
1196
1197 if( fSuccess != int64_int[i].fExpected )
1198 {
1199 printf("Error in case int64_int throw: %I64X, %I64X, expected = %s\n", int64_int[i].x, int64_int[i].y, int64_int[i].fExpected ? "true" : "false");
1200 }
1201 }
1202}
1203
1204MultTest< __int64, unsigned __int32 > int64_uint[] =
1205{

Callers 1

MultVerifyFunction · 0.70

Calls 1

SafeMultiplyFunction · 0.70

Tested by

no test coverage detected