Replaced test values for hexfloat and printf to avoid ambiguity (#2425)

Fixes #1335 according to the issue description. 

@alycm replaced with straightforward values in terms of hex float
representation
This commit is contained in:
Marcin Hajder
2026-01-13 18:44:39 +01:00
committed by GitHub
parent 6774fc1dc3
commit 02a3c7e609
2 changed files with 46 additions and 15 deletions

View File

@@ -26,8 +26,11 @@ static void intRefBuilder(printDataGenParameters&, char*, const size_t);
static void halfRefBuilder(printDataGenParameters&, char* rResult,
const size_t);
static void floatRefBuilder(printDataGenParameters&, char* rResult, const size_t);
static bool floatRefTest(const char* refResult, const char* analysisBuffer);
static void doubleRefBuilder(printDataGenParameters&, char* rResult,
const size_t);
static bool doubleRefTest(const char* refResult, const char* analysisBuffer);
static void octalRefBuilder(printDataGenParameters&, char*, const size_t);
static void unsignedRefBuilder(printDataGenParameters&, char*, const size_t);
static void hexRefBuilder(printDataGenParameters&, char*, const size_t);
@@ -468,12 +471,12 @@ std::vector<printDataGenParameters> printFloatGenParameters = {
// Double argument representing floating-point,in [-]xh.hhhhpAd style
{ { "%.6a" }, "0.1f" },
{ { "%.6a" }, "0.5f", 0, 0, 0, 0, 0, 0, 0, 0, true },
//(Minimum)Ten-wide,Double argument representing floating-point,in
// xh.hhhhpAd style,default(right)-justified
{ { "%10.2a" }, "9990.235f" },
{ { "%10.2a" }, "1.5f", 0, 0, 0, 0, 0, 0, 0, 0, true },
//(Minimum)Ten-wide,two positions after the decimal,with
// a blank space inserted before the value, default(right)-justified
@@ -502,8 +505,9 @@ testCase testCaseFloat = {
floatRefBuilder,
kfloat
kfloat,
floatRefTest
};
//==============================================
@@ -673,12 +677,12 @@ std::vector<printDataGenParameters> printDoubleGenParameters = {
// Double argument representing floating-point,in [-]xh.hhhhpAd style
{ { "%.6a" }, "0.1" },
{ { "%.6a" }, "0.5", 0, 0, 0, 0, 0, 0, 0, 0, true },
//(Minimum)Ten-wide,Double argument representing floating-point,in
// xh.hhhhpAd style,default(right)-justified
{ { "%10.2a" }, "9990.235" },
{ { "%10.2a" }, "1.5", 0, 0, 0, 0, 0, 0, 0, 0, true },
};
//---------------------------------------------------------
@@ -697,8 +701,9 @@ testCase testCaseDouble = {
doubleRefBuilder,
kdouble
kdouble,
doubleRefTest
};
//==============================================
@@ -1757,7 +1762,15 @@ size_t verifyOutputBuffer(char *analysisBuffer,testCase* pTestCase,size_t testId
return !std::regex_match(analysisBuffer, nanRegex);
}
return strcmp(analysisBuffer, pTestCase->_correctBuffer[testId].c_str());
size_t ret =
strcmp(analysisBuffer, pTestCase->_correctBuffer[testId].c_str());
if (ret != 0 && pTestCase->_genParameters[testId].allowFallbackTest
&& pTestCase->fallbackTestFN)
if (pTestCase->fallbackTestFN(
analysisBuffer, pTestCase->_correctBuffer[testId].c_str()))
return 0;
return ret;
}
static void intRefBuilder(printDataGenParameters& params, char* refResult, const size_t refSize)
@@ -1781,6 +1794,13 @@ static void floatRefBuilder(printDataGenParameters& params, char* refResult, con
strtof(params.dataRepresentation, NULL));
}
static bool floatRefTest(const char* refResult, const char* analysisBuffer)
{
float test = strtof(analysisBuffer, NULL);
float expected = strtof(refResult, NULL);
return test == expected;
}
static void doubleRefBuilder(printDataGenParameters& params, char* refResult,
const size_t refSize)
{
@@ -1788,6 +1808,13 @@ static void doubleRefBuilder(printDataGenParameters& params, char* refResult,
strtod(params.dataRepresentation, NULL));
}
static bool doubleRefTest(const char* refResult, const char* analysisBuffer)
{
double test = strtod(analysisBuffer, NULL);
double expected = strtod(refResult, NULL);
return test == expected;
}
static void octalRefBuilder(printDataGenParameters& params, char* refResult, const size_t refSize)
{
const unsigned long int data = strtoul(params.dataRepresentation, NULL, 10);