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

Function MultVerifyIntUint64

Archive/releases/2/MultVerify.cpp:1591–1630  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1589};
1590
1591void MultVerifyIntUint64()
1592{
1593 size_t i;
1594
1595 for( i = 0; i < COUNTOF(int_uint64); ++i )
1596 {
1597 __int32 ret;
1598 if( SafeMultiply(int_uint64[i].x, int_uint64[i].y, ret) != int_uint64[i].fExpected )
1599 {
1600 //assert(false);
1601 // printf("Error in case %I64X, %I64X, expected = %s\n",
1602 // int_uint64[i].x, int_uint64[i].y, int_uint64[i].fExpected ? "true" : "false");
1603 cerr << "Error in case int_uint64: ";
1604 cerr << hex << setw(16) << setfill('0') << int_uint64[i].x << ", ";
1605 cerr << hex << setw(16) << setfill('0') << int_uint64[i].y << ", ";
1606 cerr << "expected = " << int_uint64[i].fExpected << endl;
1607 }
1608
1609 bool fSuccess = true;
1610 try
1611 {
1612 SafeInt<signed __int32> si(int_uint64[i].x);
1613 si *= int_uint64[i].y;
1614 }
1615 catch(...)
1616 {
1617 fSuccess = false;
1618 }
1619
1620 if( fSuccess != int_uint64[i].fExpected )
1621 {
1622 // printf("Error in case int_uint64 throw: %I64X, %I64X, expected = %s\n",
1623 // int_uint64[i].x, int_uint64[i].y, int_uint64[i].fExpected ? "true" : "false");
1624 cerr << "Error in case int_uint64 throw: ";
1625 cerr << hex << setw(16) << setfill('0') << int_uint64[i].x << ", ";
1626 cerr << hex << setw(16) << setfill('0') << int_uint64[i].y << ", ";
1627 cerr << "expected = " << int_uint64[i].fExpected << endl;
1628 }
1629 }
1630}
1631
1632static const MultTest< unsigned __int8, unsigned __int8 > uint8_uint8[] =
1633{

Callers 1

MultVerifyFunction · 0.70

Calls 1

SafeMultiplyFunction · 0.50

Tested by

no test coverage detected