16template <
typename T,
typename W>
19 constexpr auto min{std::numeric_limits<T>::min()};
20 constexpr auto max{std::numeric_limits<T>::max()};
22 static_assert(min >= std::numeric_limits<W>::min() / 2);
23 static_assert(max <= std::numeric_limits<W>::max() / 2);
25 auto widen = [](
T value) -> W {
return value; };
26 auto clamp = [](W value) -> W {
return std::clamp<W>(value, min, max); };
27 auto check = [](W value) -> std::optional<W> {
if (value >= min && value <= max)
return value;
else return std::nullopt; };
31 const unsigned shift = fuzzed_data_provider.
ConsumeIntegralInRange<
unsigned>(0, std::numeric_limits<W>::digits - std::numeric_limits<T>::digits);
44 TestOverflow<int8_t, int64_t>(fuzzed_data_provider);
45 TestOverflow<int16_t, int64_t>(fuzzed_data_provider);
46 TestOverflow<int32_t, int64_t>(fuzzed_data_provider);
47 TestOverflow<uint8_t, uint64_t>(fuzzed_data_provider);
48 TestOverflow<uint16_t, uint64_t>(fuzzed_data_provider);
49 TestOverflow<uint32_t, uint64_t>(fuzzed_data_provider);
#define Assert(val)
Identity function.
T ConsumeIntegralInRange(T min, T max)
#define T(expected, seed, data)
std::optional< T > CheckedAdd(const T i, const T j) noexcept
constexpr T SaturatingLeftShift(T input, unsigned shift) noexcept
Left bit shift with safe minimum and maximum values.
T SaturatingAdd(const T i, const T j) noexcept
constexpr std::optional< T > CheckedLeftShift(T input, unsigned shift) noexcept
Left bit shift with overflow checking.