language-extensions/R/test/src/RExtensionGetOutputParamTests.cpp
//----------------------------------------------------------------------------------------------
// Name: RExtensionApiTest::GetRawOutputParam
//
// Description:
//  Tests raw (binary) output param value and strLenOrInd is as expected.
//
:GetRawOutputParam
Description:
Tests raw (binary) output param value and strLenOrInd is as expected.
: GetRawOutputParam Description : Tests raw ( binary ) output param value and strLenOrInd is as expected .
void RExtensionApiTests::GetRawOutputParam(
		vector<SQLCHAR*>   expectedParamValues,
		vector<SQLINTEGER> expectedStrLenOrInd)
	{
		ASSERT_EQ(expectedParamValues.size(), expectedStrLenOrInd.size());
		for (SQLUSMALLINT paramNumber = 0; paramNumber < expectedParamValues.size(); ++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);
			EXPECT_EQ(strLen_or_Ind, expectedStrLenOrInd[paramNumber]);
			if (expectedParamValues[paramNumber] != nullptr)
			{
				EXPECT_NE(paramValue, nullptr);
				for (SQLINTEGER i = 0; i < strLen_or_Ind; ++i)
				{
					EXPECT_EQ(*(static_cast<SQLCHAR*>(paramValue) + i),
						*(expectedParamValues[paramNumber] + i));
				}
			}
			else
			{
				EXPECT_EQ(paramValue, nullptr);
			}
		}
	}
void RExtensionApiTests :: GetRawOutputParam ( vector < SQLCHAR * > expectedParamValues , vector < SQLINTEGER > expectedStrLenOrInd ) { ASSERT_EQ ( expectedParamValues . size ( ) , expectedStrLenOrInd . size ( ) ) ; for ( SQLUSMALLINT paramNumber = 0 ; paramNumber < expectedParamValues . size ( ) ; ++ 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 ) ; EXPECT_EQ ( strLen_or_Ind , expectedStrLenOrInd [ paramNumber ] ) ; if ( expectedParamValues [ paramNumber ] != nullptr ) { EXPECT_NE ( paramValue , nullptr ) ; for ( SQLINTEGER i = 0 ; i < strLen_or_Ind ; ++ i ) { EXPECT_EQ ( * ( static_cast < SQLCHAR * > ( paramValue ) + i ) , * ( expectedParamValues [ paramNumber ] + i ) ) ; } } else { EXPECT_EQ ( paramValue , nullptr ) ; } } }
Name: RExtensionApiTest::GetRawOutputParam
Description:
Tests raw (binary) output param value and strLenOrInd is as expected.
Name : RExtensionApiTest :: GetRawOutputParam Description : Tests raw ( binary ) output param value and strLenOrInd is as expected .