language-extensions/R/test/src/RExtensionGetOutputParamTests.cpp
//----------------------------------------------------------------------------------------------
// Name: GetIntegerOutputParamTest
//
// Description:
//  Tests multiple SQLINTEGER values.
//
GetIntegerOutputParamTest
Description:
Tests multiple SQLINTEGER values.
GetIntegerOutputParamTest Description : Tests multiple SQLINTEGER values .
TEST_F(RExtensionApiTests, GetIntegerOutputParamTest)
	{
		string scriptString = "param1 <- as.integer(" + to_string(m_MaxInt) + ");"
			"param2 <- as.integer(" + to_string(m_MinInt) + ");"
			"param3 <- c(as.integer(5), as.integer(4));"
			"param4 <- as.integer(NA);"
			"param5 <- as.integer()";
		InitializeSession(
			0,    inputSchemaColumnsNumber
			scriptString,
			5);   parametersNumber
		vector<shared_ptr<SQLINTEGER>> initParamValues = {
			make_shared<SQLINTEGER>(0),
			make_shared<SQLINTEGER>(0),
			make_shared<SQLINTEGER>(0),
			make_shared<SQLINTEGER>(0),
			nullptr };
		vector<SQLINTEGER> strLenOrInd = { 0, 0, 0, 0, SQL_NULL_DATA};
		vector<SQLSMALLINT> inputOutputTypes(initParamValues.size(), SQL_PARAM_INPUT_OUTPUT);
		InitParam<SQLINTEGER, Rcpp::IntegerVector, SQL_C_SLONG>(
			initParamValues,
			strLenOrInd,
			inputOutputTypes,
			false);   validate
		SQLUSMALLINT outputSchemaColumnsNumber = 0;
		SQLRETURN result = (*sm_executeFuncPtr)(
			*m_sessionId,
			m_taskId,
			0,        rowsNumber
			nullptr,  dataSet
			nullptr,  strLen_or_Ind
			&outputSchemaColumnsNumber);
		ASSERT_EQ(result, SQL_SUCCESS);
		EXPECT_EQ(outputSchemaColumnsNumber, 0);
		 Test max INT value, min INT value with respect to R,
		 a normal value, NA value and
		 a NULL INT value.
		vector<shared_ptr<SQLINTEGER>> expectedParamValues = {
			make_shared<SQLINTEGER>(m_MaxInt),
			make_shared<SQLINTEGER>(m_MinInt),
			make_shared<SQLINTEGER>(5),
			make_shared<SQLINTEGER>(R_NaInt),
			nullptr };
		vector<SQLINTEGER> expectedStrLenOrInd = { m_IntSize, m_IntSize, m_IntSize,
			SQL_NULL_DATA, SQL_NULL_DATA};
		GetOutputParam<SQLINTEGER>(
			expectedParamValues,
			expectedStrLenOrInd);
	}
TEST_F ( RExtensionApiTests , GetIntegerOutputParamTest ) { string scriptString = " " + to_string ( m_MaxInt ) + " " " " + to_string ( m_MinInt ) + " " " " " " " " ; InitializeSession ( 0 , scriptString , 5 ) ; vector < shared_ptr < SQLINTEGER > > initParamValues = { make_shared < SQLINTEGER > ( 0 ) , make_shared < SQLINTEGER > ( 0 ) , make_shared < SQLINTEGER > ( 0 ) , make_shared < SQLINTEGER > ( 0 ) , nullptr } ; vector < SQLINTEGER > strLenOrInd = { 0 , 0 , 0 , 0 , SQL_NULL_DATA } ; vector < SQLSMALLINT > inputOutputTypes ( initParamValues . size ( ) , SQL_PARAM_INPUT_OUTPUT ) ; 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 ) ; vector < shared_ptr < SQLINTEGER > > expectedParamValues = { make_shared < SQLINTEGER > ( m_MaxInt ) , make_shared < SQLINTEGER > ( m_MinInt ) , make_shared < SQLINTEGER > ( 5 ) , make_shared < SQLINTEGER > ( R_NaInt ) , nullptr } ; vector < SQLINTEGER > expectedStrLenOrInd = { m_IntSize , m_IntSize , m_IntSize , SQL_NULL_DATA , SQL_NULL_DATA } ; GetOutputParam < SQLINTEGER > ( expectedParamValues , expectedStrLenOrInd ) ; }
Name: GetIntegerOutputParamTest
Description:
Tests multiple SQLINTEGER values.
Name : GetIntegerOutputParamTest Description : Tests multiple SQLINTEGER values .
// Initialize with a Session that executes the above script // that sets output parameters. // // inputSchemaColumnsNumber // parametersNumber // validate // rowsNumber // dataSet // strLen_or_Ind // Test max INT value, min INT value with respect to R, // a normal value, NA value and // a NULL INT value. //