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

Function DivVerifyInt64Int64

Archive/releases/2/DivVerify.cpp:1601–1649  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1599};
1600
1601void DivVerifyInt64Int64()
1602{
1603 size_t i;
1604
1605 for( i = 0; i < sizeof(int64_int64)/sizeof(int64_int64[0]); ++i )
1606 {
1607 __int64 ret;
1608 if( SafeDivide(int64_int64[i].x, int64_int64[i].y, ret) != int64_int64[i].fExpected )
1609 {
1610 //assert(false);
1611 printf("Error in case int64_int64: %I64X, %I64X, expected = %s\n", int64_int64[i].x, int64_int64[i].y, int64_int64[i].fExpected ? "true" : "false");
1612 }
1613
1614 // Now test throwing version
1615 bool fSuccess = true;
1616 try
1617 {
1618 SafeInt<__int64> si(int64_int64[i].x);
1619 si /= int64_int64[i].y;
1620 }
1621 catch(...)
1622 {
1623 fSuccess = false;
1624 }
1625
1626 if( fSuccess != int64_int64[i].fExpected )
1627 {
1628 printf("Error in case int64_int64 throw: %I64X, %I64X, expected = %s\n", int64_int64[i].x, int64_int64[i].y, int64_int64[i].fExpected ? "true" : "false");
1629 }
1630
1631 // Also need to test the version that assigns back out
1632 // to a plain int, as it has different logic
1633 fSuccess = true;
1634 try
1635 {
1636 __int64 x(int64_int64[i].x);
1637 x /= SafeInt<__int64>(int64_int64[i].y);
1638 }
1639 catch(...)
1640 {
1641 fSuccess = false;
1642 }
1643
1644 if( fSuccess != int64_int64[i].fExpected )
1645 {
1646 printf("Error in case int64_int64 throw: %I64X, %I64X, expected = %s\n", int64_int64[i].x, int64_int64[i].y, int64_int64[i].fExpected ? "true" : "false");
1647 }
1648 }
1649}
1650
1651void DivVerifyInt64Int64_2()
1652{

Callers 1

DivVerifyFunction · 0.70

Calls 1

SafeDivideFunction · 0.50

Tested by

no test coverage detected