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

Function MultVerifyInt64Int64

Test/MultVerify.cpp:934–973  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

932};
933
934void MultVerifyInt64Int64()
935{
936 size_t i;
937
938 for( i = 0; i < COUNTOF(int64_int64); ++i )
939 {
940 std::int64_t ret;
941 if( SafeMultiply(int64_int64[i].x, int64_int64[i].y, ret) != int64_int64[i].fExpected )
942 {
943 //assert(false);
944 // printf("Error in case %I64X, %I64X, expected = %s\n",
945 // int64_int64[i].x, int64_int64[i].y, int64_int64[i].fExpected ? "true" : "false");
946 cerr << "Error in case int64_int64: ";
947 cerr << hex << setw(16) << setfill('0') << int64_int64[i].x << ", ";
948 cerr << hex << setw(16) << setfill('0') << int64_int64[i].y << ", ";
949 cerr << "expected = " << int64_int64[i].fExpected << endl;
950 }
951
952 bool fSuccess = true;
953 try
954 {
955 SafeInt<std::int64_t> si(int64_int64[i].x);
956 si *= int64_int64[i].y;
957 }
958 catch(...)
959 {
960 fSuccess = false;
961 }
962
963 if( fSuccess != int64_int64[i].fExpected )
964 {
965 // printf("Error in case int64_int64 throw: %I64X, %I64X, expected = %s\n",
966 // int64_int64[i].x, int64_int64[i].y, int64_int64[i].fExpected ? "true" : "false");
967 cerr << "Error in case int64_int64 throw: ";
968 cerr << hex << setw(16) << setfill('0') << int64_int64[i].x << ", ";
969 cerr << hex << setw(16) << setfill('0') << int64_int64[i].y << ", ";
970 cerr << "expected = " << int64_int64[i].fExpected << endl;
971 }
972 }
973}
974
975static const MultTest< std::int64_t, std::uint64_t > int64_uint64[] =
976{

Callers 1

MultVerifyFunction · 0.70

Calls 1

SafeMultiplyFunction · 0.50

Tested by

no test coverage detected