Skip to content

Commit

Permalink
[Fix] Tests: Work around different floating-point parsing behaviour i…
Browse files Browse the repository at this point in the history
  • Loading branch information
sagamusix committed Aug 26, 2023
1 parent 886a4ff commit ac736a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/mpt/parse/tests/tests_parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ MPT_TEST_GROUP_INLINE("mpt/parse")
#endif

MPT_TEST_EXPECT_EQUAL(mpt::parse<float>(mpt::format<std::string>::val(-87.0)), -87.0f);
#if !MPT_OS_DJGPP
// VS2022 17.7.2 parses "-5e-07" as -5.0000000000000004e-06 instead of -4.9999999999999998e-07 which is closer
// https://developercommunity.visualstudio.com/t/Parsing-double-from-stringstream-returns/10450694
#if !MPT_OS_DJGPP && !(MPT_COMPILER_MSVC && MPT_COMPILER_MSVC_VERSION == MPT_COMPILER_MAKE_VERSION2(2022, 7))
MPT_TEST_EXPECT_EQUAL(mpt::parse<double>(mpt::format<std::string>::val(-0.5e-6)), -0.5e-6);
#endif

Expand Down
4 changes: 3 additions & 1 deletion test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,9 @@ static MPT_NOINLINE void TestStringFormatting()
#endif

VERIFY_EQUAL(mpt::parse<float>(mpt::afmt::val(-87.0)), -87.0f);
#if !MPT_OS_DJGPP
// VS2022 17.7.2 parses "-5e-07" as -5.0000000000000004e-06 instead of -4.9999999999999998e-07 which is closer
// https://developercommunity.visualstudio.com/t/Parsing-double-from-stringstream-returns/10450694
#if !MPT_OS_DJGPP && !(MPT_COMPILER_MSVC && MPT_COMPILER_MSVC_VERSION == MPT_COMPILER_MAKE_VERSION2(2022, 7))
VERIFY_EQUAL(mpt::parse<double>(mpt::afmt::val(-0.5e-6)), -0.5e-6);
#endif

Expand Down

0 comments on commit ac736a2

Please sign in to comment.