language-extensions/R/test/src/RExtensionGetOutputParamTests.cpp
//----------------------------------------------------------------------------------------------
// Name: GetInvalidOutputParamTest
//
// Description:
//  Negative tests.
//
GetInvalidOutputParamTest
Description:
Negative tests.
GetInvalidOutputParamTest Description : Negative tests .
TEST_F(RExtensionApiTests, GetInvalidOutputParamTest)
	{
		InitializeSession(
			0,   inputSchemaColumnsNumber
			"",  scriptString
			2);  parametersNumber
		vector<shared_ptr<SQLINTEGER>> initParamValues = {
			make_shared<SQLINTEGER>(0) };
		vector<SQLINTEGER> strLenOrInd = { 0 };
		vector<SQLSMALLINT> inputOutputTypes = { SQL_PARAM_INPUT };
		InitParam<SQLINTEGER, Rcpp::IntegerVector, SQL_C_SLONG>(
			initParamValues,
			strLenOrInd,
			inputOutputTypes,
			false);   validate
		SQLUSMALLINT outputSchemaColumnsNumber = 0;
		SQLRETURN result = (*sm_executeFuncPtr)(
			*m_sessionId,
			m_taskId,
			0,
			nullptr,  dataSet
			nullptr,  strLen_or_Ind
			&outputSchemaColumnsNumber);
		ASSERT_EQ(result, SQL_SUCCESS);
		EXPECT_EQ(outputSchemaColumnsNumber, 0);
		SQLPOINTER paramValue = nullptr;
		SQLINTEGER strLen_or_Ind = 0;
		result = SQL_SUCCESS;
		 Test input parameter requested as output.
		result = (*sm_getOutputParamFuncPtr)(
			*m_sessionId,
			m_taskId,
			0,  paramNumber
			&paramValue,
			&strLen_or_Ind);
		ASSERT_EQ(result, SQL_ERROR);
		 Test uninitialized parameter.
		result = SQL_SUCCESS;
		result = (*sm_getOutputParamFuncPtr)(
			*m_sessionId,
			m_taskId,
			1,  paramNumber
			&paramValue,
			&strLen_or_Ind);
		ASSERT_EQ(result, SQL_ERROR);
	}
TEST_F ( RExtensionApiTests , GetInvalidOutputParamTest ) { InitializeSession ( 0 , " " , 2 ) ; vector < shared_ptr < SQLINTEGER > > initParamValues = { make_shared < SQLINTEGER > ( 0 ) } ; vector < SQLINTEGER > strLenOrInd = { 0 } ; vector < SQLSMALLINT > inputOutputTypes = { SQL_PARAM_INPUT } ; InitParam < SQLINTEGER , Rcpp :: IntegerVector , SQL_C_SLONG > ( initParamValues , strLenOrInd , inputOutputTypes , false ) ; SQLUSMALLINT outputSchemaColumnsNumber = 0 ; SQLRETURN result = ( * sm_executeFuncPtr ) ( * m_sessionId , m_taskId , 0 , nullptr , nullptr , & outputSchemaColumnsNumber ) ; ASSERT_EQ ( result , SQL_SUCCESS ) ; EXPECT_EQ ( outputSchemaColumnsNumber , 0 ) ; SQLPOINTER paramValue = nullptr ; SQLINTEGER strLen_or_Ind = 0 ; result = SQL_SUCCESS ; result = ( * sm_getOutputParamFuncPtr ) ( * m_sessionId , m_taskId , 0 , & paramValue , & strLen_or_Ind ) ; ASSERT_EQ ( result , SQL_ERROR ) ; result = SQL_SUCCESS ; result = ( * sm_getOutputParamFuncPtr ) ( * m_sessionId , m_taskId , 1 , & paramValue , & strLen_or_Ind ) ; ASSERT_EQ ( result , SQL_ERROR ) ; }
Name: GetInvalidOutputParamTest
Description:
Negative tests.
Name : GetInvalidOutputParamTest Description : Negative tests .
// Initialize a Session with empty script and 2 parameters. // // inputSchemaColumnsNumber // scriptString // parametersNumber // validate // dataSet // strLen_or_Ind // Test input parameter requested as output. // // paramNumber // Test uninitialized parameter. // // paramNumber