language-extensions/R/test/src/RExtensionGetOutputParamTests.cpp
//----------------------------------------------------------------------------------------------
// Name: GetRealOutputParamTest
//
// Description:
//  Tests multiple real values.
//
GetRealOutputParamTest
Description:
Tests multiple real values.
GetRealOutputParamTest Description : Tests multiple real values .
TEST_F(RExtensionApiTests, GetRealOutputParamTest)
	{
		string scriptString = "param1 <- " + to_string(m_MaxReal) + ";"
			"param2 <- " + to_string(m_MinReal) + ";"
			"param3 <- 2.3e4;"
			"param4 <- as.numeric(NA);"
			"param5 <- as.numeric()";
		InitializeSession(
			0,    inputSchemaColumnsNumber
			scriptString,
			5);   parametersNumber
		vector<shared_ptr<SQLREAL>> initParamValues = {
			make_shared<SQLREAL>(0),
			make_shared<SQLREAL>(0),
			make_shared<SQLREAL>(0),
			make_shared<SQLREAL>(0),
			nullptr };
		vector<SQLINTEGER> strLenOrInd = { 0, 0, 0, 0, SQL_NULL_DATA };
		vector<SQLSMALLINT> inputOutputTypes(initParamValues.size(), SQL_PARAM_INPUT_OUTPUT);
		InitParam<SQLREAL, Rcpp::NumericVector, SQL_C_FLOAT>(
			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 FLOAT(24), min FLOAT(24), a normal, NAN and nullptr REAL values
		vector<shared_ptr<SQLREAL>> expectedParamValues = {
			make_shared<SQLREAL>(m_MaxReal),
			make_shared<SQLREAL>(m_MinReal),
			make_shared<SQLREAL>(2.3e4),
			make_shared<SQLREAL>(NAN),
			nullptr };
		vector<SQLINTEGER> expectedStrLenOrInd = { m_RealSize, m_RealSize, m_RealSize,
			SQL_NULL_DATA, SQL_NULL_DATA};
		GetOutputParam<SQLREAL>(
			expectedParamValues,
			expectedStrLenOrInd);
	}
TEST_F ( RExtensionApiTests , GetRealOutputParamTest ) { string scriptString = " " + to_string ( m_MaxReal ) + " " " " + to_string ( m_MinReal ) + " " " " " " " " ; InitializeSession ( 0 , scriptString , 5 ) ; vector < shared_ptr < SQLREAL > > initParamValues = { make_shared < SQLREAL > ( 0 ) , make_shared < SQLREAL > ( 0 ) , make_shared < SQLREAL > ( 0 ) , make_shared < SQLREAL > ( 0 ) , nullptr } ; vector < SQLINTEGER > strLenOrInd = { 0 , 0 , 0 , 0 , SQL_NULL_DATA } ; vector < SQLSMALLINT > inputOutputTypes ( initParamValues . size ( ) , SQL_PARAM_INPUT_OUTPUT ) ; InitParam < SQLREAL , Rcpp :: NumericVector , SQL_C_FLOAT > ( 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 < SQLREAL > > expectedParamValues = { make_shared < SQLREAL > ( m_MaxReal ) , make_shared < SQLREAL > ( m_MinReal ) , make_shared < SQLREAL > ( 2.3e4 ) , make_shared < SQLREAL > ( NAN ) , nullptr } ; vector < SQLINTEGER > expectedStrLenOrInd = { m_RealSize , m_RealSize , m_RealSize , SQL_NULL_DATA , SQL_NULL_DATA } ; GetOutputParam < SQLREAL > ( expectedParamValues , expectedStrLenOrInd ) ; }
Name: GetRealOutputParamTest
Description:
Tests multiple real values.
Name : GetRealOutputParamTest Description : Tests multiple real values .
// Initialize with a Session that executes the above script // that sets output parameters. // // inputSchemaColumnsNumber // parametersNumber // validate // rowsNumber // dataSet // strLen_or_Ind // Test max FLOAT(24), min FLOAT(24), a normal, NAN and nullptr REAL values //