From 78f7676bb87f273869f156e2e1fd145c7caec0fa Mon Sep 17 00:00:00 2001 From: Gautam Dhar Date: Wed, 25 Sep 2024 02:16:32 +0530 Subject: [PATCH] 2. testing floating-point changes for macos pre and post arm64 --- tests/testFloatingPointPrecision.cpp | 10 ++++++++++ tests/testUserDefinedConverter_lowerPrecision.cpp | 10 ++++++++-- tests/utilities.h | 5 +++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/tests/testFloatingPointPrecision.cpp b/tests/testFloatingPointPrecision.cpp index 5c9c680..cf95c1b 100644 --- a/tests/testFloatingPointPrecision.cpp +++ b/tests/testFloatingPointPrecision.cpp @@ -52,7 +52,13 @@ int main() try { std::string expected_float_8d589973ep9[] = { "8589973504", +#if MACH_MACOS_ARRAY_IDX == MACH_POST_MACOS14_ARM_CLANG + || MACH_MACOS_ARRAY_IDX == MACH_PRE_MACOS14_CLANG "8.5899735e+09", // macOS +//#elif MACH_MACOS_ARRAY_IDX == MACH_POST_MACOS14_ARM_GNU +#else // default MACH_MACOS_ARRAY_IDX == MACH_PRE_MACOS14_GNU + "8589973504", +#endif "8589973504", }; checkRoundTripConversion_txt2Val2txt("testFloatingPointPrecision-1", "8.589973e+9", 8.589973e9f, expected_float_8d589973ep9[indexOS]); @@ -129,7 +135,11 @@ int main() ((indexOS==1)?7:std::numeric_limits::digits10) ); // macOS std::string expected_longdouble_5d3123412en38[] = { "5.3123412e-38", +#if MACH_MACOS_ARRAY_IDX == MACH_POST_MACOS14_ARM_CLANG + "5.31234120000000035e-38", +#else "5.3123412000000000001e-38", // macOS +#endif "5.3123412e-38", }; checkRoundTripConversion_txt2Val2txt("testFloatingPointPrecision-13", "5.3123412e-38", 5.3123412E-38L, expected_longdouble_5d3123412en38[indexOS], diff --git a/tests/testUserDefinedConverter_lowerPrecision.cpp b/tests/testUserDefinedConverter_lowerPrecision.cpp index c822977..a0fcf06 100644 --- a/tests/testUserDefinedConverter_lowerPrecision.cpp +++ b/tests/testUserDefinedConverter_lowerPrecision.cpp @@ -83,8 +83,8 @@ int main() "2.1234567890123456789", 2.1234567890123456789, "2.1234567890123", getLowerDecimalPrecision()); // 14 digits std::string expected_longDouble_1d123456789012345678901[] = { "3.1234567890123457", #if MACH_MACOS_ARRAY_IDX == MACH_POST_MACOS14_ARM_CLANG + || MACH_MACOS_ARRAY_IDX == MACH_POST_MACOS14_ARM_GNU "3.1234567890123", -//#elif MACH_MACOS_ARRAY_IDX == MACH_POST_MACOS14_ARM_GNU //#elif MACH_MACOS_ARRAY_IDX == MACH_PRE_MACOS14_CLANG #else // default MACH_MACOS_ARRAY_IDX == MACH_PRE_MACOS14_GNU "3.1234567890123457", @@ -97,8 +97,8 @@ int main() (indexOS==0)?16:( (indexOS==1)? #if MACH_MACOS_ARRAY_IDX == MACH_POST_MACOS14_ARM_CLANG + || MACH_MACOS_ARRAY_IDX == MACH_POST_MACOS14_ARM_GNU 14 -//#elif MACH_MACOS_ARRAY_IDX == MACH_POST_MACOS14_ARM_GNU //#elif MACH_MACOS_ARRAY_IDX == MACH_PRE_MACOS14_CLANG #else // default MACH_MACOS_ARRAY_IDX == MACH_PRE_MACOS14_GNU 16 @@ -111,7 +111,13 @@ int main() "9007199254740993", 9007199254740993.0, "9.007199254741e+15", getLowerDecimalPrecision()); std::string expected_longDouble_9007199254740993[] = { "9007199254740993", +#if MACH_MACOS_ARRAY_IDX == MACH_POST_MACOS14_ARM_CLANG + "9.007199254741e+15", +//#elif MACH_MACOS_ARRAY_IDX == MACH_POST_MACOS14_ARM_GNU +//#elif MACH_MACOS_ARRAY_IDX == MACH_PRE_MACOS14_CLANG +#else // default MACH_MACOS_ARRAY_IDX == MACH_PRE_MACOS14_GNU "9007199254740993", +#endif "9.007199254741e+15" }; // Windows checkRoundTripConversion_txt2Val2txt, ConvertFromVal_lDP>("testUserDefinedConverter_lowerPrecision-8", diff --git a/tests/utilities.h b/tests/utilities.h index d85ac85..1049c9e 100644 --- a/tests/utilities.h +++ b/tests/utilities.h @@ -35,7 +35,8 @@ void checkRoundTripConversion_txt2Val2txt( const std::string& testID, unittest::ExpectEqual(T, valExpected, valConv); const std::string strRoundtripActual = TConvertFromVal::ToStr(valConv); - std::cout << "testID = " << testID << " , strInput = " << strInput << std::endl; + std::cout << "testID = " << testID << " , strInput = " << strInput << " : decimalPrecision = " << decimalPrecision << std::endl; + std::cout << "strRoundtripExpected = " << strRoundtripExpected << " : strRoundtripActual = " << strRoundtripActual << std::endl; unittest::ExpectEqual(std::string, strRoundtripExpected, strRoundtripActual); if(strInput.compare(strRoundtripActual)!=0) @@ -109,7 +110,7 @@ void checkRoundTripConversion_txt2Val2txt( const std::string& testID, } } else if(decSep_input == std::string::npos && decSep_actual == std::string::npos) { std::cout << "integer significant-digits check" << std::endl; - // both input and round-trip-string have decimal seperator + // both input and round-trip-string DONOT have decimal seperator // for e.g.: '8589973000' std::string significantDigits_input = _strInput.substr(0, static_cast(decimalPrecision)); std::string significantDigits_actual = _strRoundtripActual.substr(0, static_cast(decimalPrecision));