From ab16a3e91a2297e76b71420b44eff227a944d26e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20G=C3=BCndling?= Date: Sun, 27 Oct 2024 23:29:12 +0100 Subject: [PATCH] fix level -4 --- include/osr/types.h | 5 ++--- test/level_test.cc | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/osr/types.h b/include/osr/types.h index 12ac5f9..f36ebf9 100644 --- a/include/osr/types.h +++ b/include/osr/types.h @@ -136,10 +136,9 @@ constexpr direction to_direction(std::string_view s) { // level using level_t = cista::strong; -// would be -4.0 as float but represented as NaN constexpr auto const kNoLevel = level_t{0U}; -constexpr auto const kMinLevel = -3.75F; -constexpr auto const kMaxLevel = 3.75F; +constexpr auto const kMinLevel = -4.0F; +constexpr auto const kMaxLevel = 3.5F; constexpr level_t to_level(float const f) { return level_t{static_cast((f - kMinLevel) / 0.25F) + 1U}; diff --git a/test/level_test.cc b/test/level_test.cc index b7807e4..794e990 100644 --- a/test/level_test.cc +++ b/test/level_test.cc @@ -15,6 +15,9 @@ TEST(osr, level) { auto const lvl_4 = to_float(to_level(4.0F)); EXPECT_EQ(4.0F, lvl_4); + auto const lvl_negative_4 = to_float(to_level(-4.0F)); + EXPECT_EQ(-4.0F, lvl_negative_4); + auto const lvl_minus_3 = to_float(to_level(-3.0F)); EXPECT_EQ(-3.0F, lvl_minus_3); } \ No newline at end of file