| 1705 | }; |
| 1706 | |
| 1707 | void DivVerifyInt64Int32() |
| 1708 | { |
| 1709 | size_t i; |
| 1710 | |
| 1711 | for( i = 0; i < sizeof(int64_int32)/sizeof(int64_int32[0]); ++i ) |
| 1712 | { |
| 1713 | std::int64_t ret; |
| 1714 | if( SafeDivide(int64_int32[i].x, int64_int32[i].y, ret) != int64_int32[i].fExpected ) |
| 1715 | { |
| 1716 | //assert(false); |
| 1717 | printf("Error in case int64_int32: %I64X, %I64X, expected = %s\n", int64_int32[i].x, int64_int32[i].y, int64_int32[i].fExpected ? "true" : "false"); |
| 1718 | } |
| 1719 | |
| 1720 | // Now test throwing version |
| 1721 | bool fSuccess = true; |
| 1722 | try |
| 1723 | { |
| 1724 | SafeInt<std::int64_t> si(int64_int32[i].x); |
| 1725 | si /= int64_int32[i].y; |
| 1726 | } |
| 1727 | catch(...) |
| 1728 | { |
| 1729 | fSuccess = false; |
| 1730 | } |
| 1731 | |
| 1732 | if( fSuccess != int64_int32[i].fExpected ) |
| 1733 | { |
| 1734 | printf("Error in case int64_int32 throw: %I64X, %I64X, expected = %s\n", int64_int32[i].x, int64_int32[i].y, int64_int32[i].fExpected ? "true" : "false"); |
| 1735 | } |
| 1736 | |
| 1737 | // Also need to test the version that assigns back out |
| 1738 | // to a plain int, as it has different logic |
| 1739 | fSuccess = true; |
| 1740 | try |
| 1741 | { |
| 1742 | std::int64_t x(int64_int32[i].x); |
| 1743 | x /= SafeInt<std::int32_t>(int64_int32[i].y); |
| 1744 | } |
| 1745 | catch(...) |
| 1746 | { |
| 1747 | fSuccess = false; |
| 1748 | } |
| 1749 | |
| 1750 | if( fSuccess != int64_int32[i].fExpected ) |
| 1751 | { |
| 1752 | printf("Error in case int64_int32 throw: %I64X, %I64X, expected = %s\n", int64_int32[i].x, int64_int32[i].y, int64_int32[i].fExpected ? "true" : "false"); |
| 1753 | } |
| 1754 | } |
| 1755 | } |
| 1756 | |
| 1757 | DivTest< std::int64_t, std::int32_t > int64_int32_2[] = |
| 1758 | { |
no test coverage detected