From 7778d09850eed52b01f47ef1027a8d71aef275fe Mon Sep 17 00:00:00 2001 From: Chip Hogg Date: Mon, 11 Dec 2023 14:37:53 -0500 Subject: [PATCH] Clean up uint16_t test a little more --- au/quantity_test.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/au/quantity_test.cc b/au/quantity_test.cc index ed310a26..ccf2bf74 100644 --- a/au/quantity_test.cc +++ b/au/quantity_test.cc @@ -725,8 +725,10 @@ TEST(WillConversionTruncate, UsesModForIntegerTypes) { TEST(IsConversionLossy, CorrectlyDiscriminatesBetweenLossyAndLosslessConversions) { // We will check literally every representable value in the type, and make sure that the result // of `is_conversion_lossy()` matches perfectly with the inability to recover the initial value. - auto test_round_trip_for_every_uint8_value = [](auto source_units, auto target_units) { - for (int i = 0; i <= 65535; ++i) { + auto test_round_trip_for_every_uint16_value = [](auto source_units, auto target_units) { + for (int i = std::numeric_limits::lowest(); + i <= std::numeric_limits::max(); + ++i) { const auto original = source_units(static_cast(i)); const auto converted = original.coerce_as(target_units); const auto round_trip = converted.coerce_as(source_units); @@ -753,10 +755,10 @@ TEST(IsConversionLossy, CorrectlyDiscriminatesBetweenLossyAndLosslessConversions }; // Inches-to-feet tests truncation. - test_round_trip_for_every_uint8_value(inches, feet); + test_round_trip_for_every_uint16_value(inches, feet); // Feet-to-inches tests overflow. - test_round_trip_for_every_uint8_value(feet, inches); + test_round_trip_for_every_uint16_value(feet, inches); } TEST(AreQuantityTypesEquivalent, RequiresSameRepAndEquivalentUnits) {