language-extensions/R/test/src/RExtensionGetOutputParamTests.cpp
//----------------------------------------------------------------------------------------------
// Name: RExtensionApiTest::GetNumericOutputParam
//
// Description:
//  Tests numeric output param value and strLenOrInd are as expected.
//
:GetNumericOutputParam
Description:
Tests numeric output param value and strLenOrInd are as expected.
: GetNumericOutputParam Description : Tests numeric output param value and strLenOrInd are as expected .
void RExtensionApiTests::GetNumericOutputParam(
		vector<SQL_NUMERIC_STRUCT> expectedParamValues,
		vector<SQLINTEGER>         expectedStrLenOrInd)
	{
		ASSERT_EQ(expectedParamValues.size(), expectedStrLenOrInd.size());
		for (SQLULEN paramNumber = 0; paramNumber < expectedParamValues.size(); ++paramNumber)
		{
			SQL_NUMERIC_STRUCT expectedParamValue = expectedParamValues[paramNumber];
			SQLPOINTER paramValue = nullptr;
			SQLINTEGER strLen_or_Ind = 0;
			SQLRETURN result = SQL_ERROR;
			result = (*sm_getOutputParamFuncPtr)(
				*m_sessionId,
				m_taskId,
				paramNumber,
				&paramValue,
				&strLen_or_Ind);
			ASSERT_EQ(result, SQL_SUCCESS);
			ASSERT_EQ(strLen_or_Ind, expectedStrLenOrInd[paramNumber]);
			if (expectedStrLenOrInd[paramNumber] != SQL_NULL_DATA)
			{
				EXPECT_NE(paramValue, nullptr);
				SQL_NUMERIC_STRUCT actualValue = *(static_cast<SQL_NUMERIC_STRUCT *>(paramValue));
				EXPECT_EQ(expectedParamValue.precision, actualValue.precision);
				EXPECT_EQ(expectedParamValue.scale, actualValue.scale);
				EXPECT_EQ(expectedParamValue.sign, actualValue.sign);
				for (SQLSMALLINT byte = 0; byte < SQL_MAX_NUMERIC_LEN; ++byte)
				{
					EXPECT_EQ(expectedParamValue.val[byte], actualValue.val[byte]);
				}
			}
			else
			{
				EXPECT_EQ(paramValue, nullptr);
			}
		}
	}
void RExtensionApiTests :: GetNumericOutputParam ( vector < SQL_NUMERIC_STRUCT > expectedParamValues , vector < SQLINTEGER > expectedStrLenOrInd ) { ASSERT_EQ ( expectedParamValues . size ( ) , expectedStrLenOrInd . size ( ) ) ; for ( SQLULEN paramNumber = 0 ; paramNumber < expectedParamValues . size ( ) ; ++ paramNumber ) { SQL_NUMERIC_STRUCT expectedParamValue = expectedParamValues [ paramNumber ] ; SQLPOINTER paramValue = nullptr ; SQLINTEGER strLen_or_Ind = 0 ; SQLRETURN result = SQL_ERROR ; result = ( * sm_getOutputParamFuncPtr ) ( * m_sessionId , m_taskId , paramNumber , & paramValue , & strLen_or_Ind ) ; ASSERT_EQ ( result , SQL_SUCCESS ) ; ASSERT_EQ ( strLen_or_Ind , expectedStrLenOrInd [ paramNumber ] ) ; if ( expectedStrLenOrInd [ paramNumber ] != SQL_NULL_DATA ) { EXPECT_NE ( paramValue , nullptr ) ; SQL_NUMERIC_STRUCT actualValue = * ( static_cast < SQL_NUMERIC_STRUCT * > ( paramValue ) ) ; EXPECT_EQ ( expectedParamValue . precision , actualValue . precision ) ; EXPECT_EQ ( expectedParamValue . scale , actualValue . scale ) ; EXPECT_EQ ( expectedParamValue . sign , actualValue . sign ) ; for ( SQLSMALLINT byte = 0 ; byte < SQL_MAX_NUMERIC_LEN ; ++ byte ) { EXPECT_EQ ( expectedParamValue . val [ byte ] , actualValue . val [ byte ] ) ; } } else { EXPECT_EQ ( paramValue , nullptr ) ; } } }
Name: RExtensionApiTest::GetNumericOutputParam
Description:
Tests numeric output param value and strLenOrInd are as expected.
Name : RExtensionApiTest :: GetNumericOutputParam Description : Tests numeric output param value and strLenOrInd are as expected .