Added printf test for long type cases (#2037)

according to work plan for issue
https://github.com/KhronosGroup/OpenCL-CTS/issues/1058
This commit is contained in:
Marcin Hajder
2024-09-24 17:42:49 +02:00
committed by GitHub
parent 8c647c1cf4
commit 661a7b08ae
3 changed files with 104 additions and 23 deletions

View File

@@ -23,6 +23,7 @@
// Helpers for generating runtime reference results
static void intRefBuilder(printDataGenParameters&, char*, const size_t);
static void longRefBuilder(printDataGenParameters&, char*, const size_t);
static void halfRefBuilder(printDataGenParameters&, char* rResult,
const size_t);
static void floatRefBuilder(printDataGenParameters&, char* rResult, const size_t);
@@ -111,6 +112,73 @@ testCase testCaseInt = {
};
//==================================
// long
//==================================
//------------------------------------------------------
// [string] format | [string] int-data representation |
//------------------------------------------------------
std::vector<printDataGenParameters> printLongGenParameters = {
//(Minimum) fifteen-wide,default(right)-justified
{ { "%5ld" }, "10000000000L" },
//(Minimum) fifteen-wide,left-justified
{ { "%-15ld" }, "-10000000000L" },
//(Minimum) fifteen-wide,default(right)-justified,zero-filled
{ { "%015ld" }, "10000000000L" },
//(Minimum) fifteen-wide,default(right)-justified,with sign
{ { "%+15ld" }, "-10000000000L" },
//(Minimum) fifteen-wide ,left-justified,with sign
{ { "%-+15ld" }, "10000000000L" },
//(Minimum) fifteen-digit(zero-filled in absent
// digits),default(right)-justified
{ { "%.15li" }, "10000000000L" },
//(Minimum)Sixteen-wide, fifteen-digit(zero-filled in absent
// digits),default(right)-justified
{ { "%-+16.15li" }, "-10000000000L" },
};
//-----------------------------------------------
// test case for long |
//-----------------------------------------------
testCase testCaseLong = {
TYPE_LONG,
correctBufferLong,
printLongGenParameters,
longRefBuilder,
klong
};
//==============================================
// half
@@ -1404,12 +1472,12 @@ testCase testCaseMixedFormat = { TYPE_MIXED_FORMAT_RANDOM,
//-------------------------------------------------------------------------------
std::vector<testCase*> allTestCase = {
&testCaseInt, &testCaseHalf, &testCaseHalfLimits,
&testCaseFloat, &testCaseFloatLimits, &testCaseDouble,
&testCaseDoubleLimits, &testCaseOctal, &testCaseUnsigned,
&testCaseHexadecimal, &testCaseChar, &testCaseString,
&testCaseFormatString, &testCaseVector, &testCaseAddrSpace,
&testCaseMixedFormat
&testCaseInt, &testCaseLong, &testCaseHalf,
&testCaseHalfLimits, &testCaseFloat, &testCaseFloatLimits,
&testCaseDouble, &testCaseDoubleLimits, &testCaseOctal,
&testCaseUnsigned, &testCaseHexadecimal, &testCaseChar,
&testCaseString, &testCaseFormatString, &testCaseVector,
&testCaseAddrSpace, &testCaseMixedFormat
};
//-----------------------------------------
@@ -1526,6 +1594,13 @@ static void intRefBuilder(printDataGenParameters& params, char* refResult, const
atoi(params.dataRepresentation));
}
static void longRefBuilder(printDataGenParameters& params, char* refResult,
const size_t refSize)
{
snprintf(refResult, refSize, params.genericFormats.front().c_str(),
atoll(params.dataRepresentation));
}
static void halfRefBuilder(printDataGenParameters& params, char* refResult,
const size_t refSize)
{