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

Function MultVerifyIntUint64

Test/MultVerify.cpp:1550–1589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1548};
1549
1550void MultVerifyIntUint64()
1551{
1552 size_t i;
1553
1554 for( i = 0; i < COUNTOF(int_uint64); ++i )
1555 {
1556 std::int32_t ret;
1557 if( SafeMultiply(int_uint64[i].x, int_uint64[i].y, ret) != int_uint64[i].fExpected )
1558 {
1559 //assert(false);
1560 // printf("Error in case %I64X, %I64X, expected = %s\n",
1561 // int_uint64[i].x, int_uint64[i].y, int_uint64[i].fExpected ? "true" : "false");
1562 cerr << "Error in case int_uint64: ";
1563 cerr << hex << setw(16) << setfill('0') << int_uint64[i].x << ", ";
1564 cerr << hex << setw(16) << setfill('0') << int_uint64[i].y << ", ";
1565 cerr << "expected = " << int_uint64[i].fExpected << endl;
1566 }
1567
1568 bool fSuccess = true;
1569 try
1570 {
1571 SafeInt<std::int32_t> si(int_uint64[i].x);
1572 si *= int_uint64[i].y;
1573 }
1574 catch(...)
1575 {
1576 fSuccess = false;
1577 }
1578
1579 if( fSuccess != int_uint64[i].fExpected )
1580 {
1581 // printf("Error in case int_uint64 throw: %I64X, %I64X, expected = %s\n",
1582 // int_uint64[i].x, int_uint64[i].y, int_uint64[i].fExpected ? "true" : "false");
1583 cerr << "Error in case int_uint64 throw: ";
1584 cerr << hex << setw(16) << setfill('0') << int_uint64[i].x << ", ";
1585 cerr << hex << setw(16) << setfill('0') << int_uint64[i].y << ", ";
1586 cerr << "expected = " << int_uint64[i].fExpected << endl;
1587 }
1588 }
1589}
1590
1591static const MultTest< std::uint8_t, std::uint8_t > uint8_uint8[] =
1592{

Callers 1

MultVerifyFunction · 0.70

Calls 1

SafeMultiplyFunction · 0.50

Tested by

no test coverage detected