language-extensions/R/test/src/RExtensionGetOutputParamTests.cpp
//----------------------------------------------------------------------------------------------
// Name: GetBigIntOutputParamTest
//
// Description:
//  Tests multiple big int values.
//
GetBigIntOutputParamTest
Description:
Tests multiple big int values.
GetBigIntOutputParamTest Description : Tests multiple big int values .
TEST_F(RExtensionApiTests, GetBigIntOutputParamTest)
	{
		string scriptString = "param1 <- " + to_string(m_MaxBigInt) + ";"
			"param2 <- " + to_string(m_MinBigInt) + ";"
			"param3 <- 9372036854775;"
			"param4 <- as.numeric(NA);"
			"param5 <- as.numeric()";
		InitializeSession(
			0,    inputSchemaColumnsNumber
			scriptString,
			5);   parametersNumber
		vector<shared_ptr<SQLBIGINT>> initParamValues = {
			make_shared<SQLBIGINT>(0),
			make_shared<SQLBIGINT>(0),
			make_shared<SQLBIGINT>(0),
			make_shared<SQLBIGINT>(0),
			nullptr };
		vector<SQLINTEGER> strLenOrInd = { 0, 0, 0, 0, SQL_NULL_DATA };
		vector<SQLSMALLINT> inputOutputTypes(initParamValues.size(), SQL_PARAM_INPUT_OUTPUT);
		InitParam<SQLBIGINT, Rcpp::NumericVector, SQL_C_SBIGINT>(
			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, min, normal, NA and NULL BIGINT values
		vector<shared_ptr<SQLBIGINT>> expectedParamValues = {
			 Even though parameter is assigned max BIGINT value in R i.e. 9.223372e+18,
			 returned paramValue when static type casted to BIGINT is the min value.
			make_shared<SQLBIGINT>(m_MinBigInt),
			make_shared<SQLBIGINT>(m_MinBigInt),
			make_shared<SQLBIGINT>(9'372'036'854'775),
			 Even though NA in R for BIGINT is NA_REAL,
			 typecasting that to a BIGINT value is MinBigInt
			make_shared<SQLBIGINT>(m_MinBigInt),
			nullptr };
		vector<SQLINTEGER> expectedStrLenOrInd = { m_BigIntSize, m_BigIntSize, m_BigIntSize,
			SQL_NULL_DATA, SQL_NULL_DATA };
		GetOutputParam<SQLBIGINT>(
			expectedParamValues,
			expectedStrLenOrInd);
	}
TEST_F ( RExtensionApiTests , GetBigIntOutputParamTest ) { string scriptString = " " + to_string ( m_MaxBigInt ) + " " " " + to_string ( m_MinBigInt ) + " " " " " " " " ; InitializeSession ( 0 , scriptString , 5 ) ; vector < shared_ptr < SQLBIGINT > > initParamValues = { make_shared < SQLBIGINT > ( 0 ) , make_shared < SQLBIGINT > ( 0 ) , make_shared < SQLBIGINT > ( 0 ) , make_shared < SQLBIGINT > ( 0 ) , nullptr } ; vector < SQLINTEGER > strLenOrInd = { 0 , 0 , 0 , 0 , SQL_NULL_DATA } ; vector < SQLSMALLINT > inputOutputTypes ( initParamValues . size ( ) , SQL_PARAM_INPUT_OUTPUT ) ; InitParam < SQLBIGINT , Rcpp :: NumericVector , SQL_C_SBIGINT > ( 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 < SQLBIGINT > > expectedParamValues = { make_shared < SQLBIGINT > ( m_MinBigInt ) , make_shared < SQLBIGINT > ( m_MinBigInt ) , make_shared < SQLBIGINT > ( 9'372'036'854'775 ) , make_shared < SQLBIGINT > ( m_MinBigInt ) , nullptr } ; vector < SQLINTEGER > expectedStrLenOrInd = { m_BigIntSize , m_BigIntSize , m_BigIntSize , SQL_NULL_DATA , SQL_NULL_DATA } ; GetOutputParam < SQLBIGINT > ( expectedParamValues , expectedStrLenOrInd ) ; }
Name: GetBigIntOutputParamTest
Description:
Tests multiple big int values.
Name : GetBigIntOutputParamTest Description : Tests multiple big int values .
// Initialize with a Session that executes the above script // that sets output parameters. // // inputSchemaColumnsNumber // parametersNumber // validate // rowsNumber // dataSet // strLen_or_Ind // Test max, min, normal, NA and NULL BIGINT values // // Even though parameter is assigned max BIGINT value in R i.e. 9.223372e+18, // returned paramValue when static type casted to BIGINT is the min value. // // Even though NA in R for BIGINT is NA_REAL, // typecasting that to a BIGINT value is MinBigInt //