Skip to content

Commit

Permalink
2. testing floating-point changes for macos pre and post arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
panchaBhuta committed Sep 24, 2024
1 parent 469733f commit 78f7676
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
10 changes: 10 additions & 0 deletions tests/testFloatingPointPrecision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>("testFloatingPointPrecision-1",
"8.589973e+9", 8.589973e9f, expected_float_8d589973ep9[indexOS]);
Expand Down Expand Up @@ -129,7 +135,11 @@ int main()
((indexOS==1)?7:std::numeric_limits<double>::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<long double>("testFloatingPointPrecision-13",
"5.3123412e-38", 5.3123412E-38L, expected_longdouble_5d3123412en38[indexOS],
Expand Down
10 changes: 8 additions & 2 deletions tests/testUserDefinedConverter_lowerPrecision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ int main()
"2.1234567890123456789", 2.1234567890123456789, "2.1234567890123", getLowerDecimalPrecision<double>()); // 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",
Expand All @@ -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
Expand All @@ -111,7 +111,13 @@ int main()
"9007199254740993", 9007199254740993.0, "9.007199254741e+15", getLowerDecimalPrecision<double>());

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<long double, converter::ConvertFromStr<long double>,
ConvertFromVal_lDP<long double>>("testUserDefinedConverter_lowerPrecision-8",
Expand Down
5 changes: 3 additions & 2 deletions tests/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<size_t>(decimalPrecision));
std::string significantDigits_actual = _strRoundtripActual.substr(0, static_cast<size_t>(decimalPrecision));
Expand Down

0 comments on commit 78f7676

Please sign in to comment.