language-extensions/R/test/src/RExtensionGetOutputParamTests.cpp
//----------------------------------------------------------------------------------------------
// Name: RExtensionApiTest::GetCharOutputParam
//
// Description:
//  Tests character output param value and strLenOrInd is as expected.
//
:GetCharOutputParam
Description:
Tests character output param value and strLenOrInd is as expected.
: GetCharOutputParam Description : Tests character output param value and strLenOrInd is as expected .
void RExtensionApiTests::GetCharOutputParam(
		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);
				string paramValueString(static_cast<char*>(paramValue),
					strLen_or_Ind);
				string expectedParamValueString(static_cast<char*>(
						static_cast<void*>(expectedParamValues[paramNumber])),
						expectedStrLenOrInd[paramNumber]);
				EXPECT_EQ(paramValueString, expectedParamValueString);
			}
			else
			{
				EXPECT_EQ(paramValue, nullptr);
			}
		}
	}
void RExtensionApiTests :: GetCharOutputParam ( 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 ) ; string paramValueString ( static_cast < char * > ( paramValue ) , strLen_or_Ind ) ; string expectedParamValueString ( static_cast < char * > ( static_cast < void * > ( expectedParamValues [ paramNumber ] ) ) , expectedStrLenOrInd [ paramNumber ] ) ; EXPECT_EQ ( paramValueString , expectedParamValueString ) ; } else { EXPECT_EQ ( paramValue , nullptr ) ; } } }
Name: RExtensionApiTest::GetCharOutputParam
Description:
Tests character output param value and strLenOrInd is as expected.
Name : RExtensionApiTest :: GetCharOutputParam Description : Tests character output param value and strLenOrInd is as expected .