language-extensions/R/test/src/RExtensionGetOutputParamTests.cpp
TEST_F(RExtensionApiTests, GetDoubleOutputParamTest)
	{
		string scriptString = "param1 <- " + to_string(m_MaxDouble) + ";"
			"param2 <- " + to_string(m_MinDouble) + ";"
			"param3 <- 1.45e38;"
			"param4 <- as.numeric(NA);"
			"param5 <- as.numeric()";

		// Initialize with a Session that executes the above script
		// that sets output parameters.
		//
		InitializeSession(
			0,   // inputSchemaColumnsNumber
			scriptString,
			5);  // parametersNumber

		vector<shared_ptr<SQLDOUBLE>> initParamValues = {
			make_shared<SQLDOUBLE>(0),
			make_shared<SQLDOUBLE>(0),
			make_shared<SQLDOUBLE>(0),
			make_shared<SQLDOUBLE>(0),
			nullptr };
		vector<SQLINTEGER> strLenOrInd = { 0, 0, 0, 0, SQL_NULL_DATA};
		vector<SQLSMALLINT> inputOutputTypes(initParamValues.size(), SQL_PARAM_INPUT_OUTPUT);

		InitParam<SQLDOUBLE, Rcpp::NumericVector, SQL_C_DOUBLE>(
			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(53), min FLOAT(53), a normal, NAN and nullptr DOUBLE values
		//
		vector<shared_ptr<SQLDOUBLE>> expectedParamValues = {
			make_shared<SQLDOUBLE>(m_MaxDouble),
			make_shared<SQLDOUBLE>(m_MinDouble),
			make_shared<SQLDOUBLE>(1.45e38),
			make_shared<SQLDOUBLE>(NAN),
			nullptr };
		vector<SQLINTEGER> expectedStrLenOrInd = { m_DoubleSize, m_DoubleSize, m_DoubleSize,
			SQL_NULL_DATA, SQL_NULL_DATA};

		GetOutputParam<SQLDOUBLE>(
			expectedParamValues,
			expectedStrLenOrInd);
	}
//----------------------------------------------------------------------------------------------
// Name: GetDoubleOutputParamTest
//
// Description:
//  Tests multiple double values.
//
GetDoubleOutputParamTest
Description:
Tests multiple double values.
GetDoubleOutputParamTest Description : Tests multiple double values .
TEST_F(RExtensionApiTests, GetDoubleOutputParamTest)
	{
		string scriptString = "param1 <- " + to_string(m_MaxDouble) + ";"
			"param2 <- " + to_string(m_MinDouble) + ";"
			"param3 <- 1.45e38;"
			"param4 <- as.numeric(NA);"
			"param5 <- as.numeric()";
		InitializeSession(
			0,    inputSchemaColumnsNumber
			scriptString,
			5);   parametersNumber
		vector<shared_ptr<SQLDOUBLE>> initParamValues = {
			make_shared<SQLDOUBLE>(0),
			make_shared<SQLDOUBLE>(0),
			make_shared<SQLDOUBLE>(0),
			make_shared<SQLDOUBLE>(0),
			nullptr };
		vector<SQLINTEGER> strLenOrInd = { 0, 0, 0, 0, SQL_NULL_DATA};
		vector<SQLSMALLINT> inputOutputTypes(initParamValues.size(), SQL_PARAM_INPUT_OUTPUT);
		InitParam<SQLDOUBLE, Rcpp::NumericVector, SQL_C_DOUBLE>(
			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(53), min FLOAT(53), a normal, NAN and nullptr DOUBLE values
		vector<shared_ptr<SQLDOUBLE>> expectedParamValues = {
			make_shared<SQLDOUBLE>(m_MaxDouble),
			make_shared<SQLDOUBLE>(m_MinDouble),
			make_shared<SQLDOUBLE>(1.45e38),
			make_shared<SQLDOUBLE>(NAN),
			nullptr };
		vector<SQLINTEGER> expectedStrLenOrInd = { m_DoubleSize, m_DoubleSize, m_DoubleSize,
			SQL_NULL_DATA, SQL_NULL_DATA};
		GetOutputParam<SQLDOUBLE>(
			expectedParamValues,
			expectedStrLenOrInd);
	}
TEST_F ( RExtensionApiTests , GetDoubleOutputParamTest ) { string scriptString = " " + to_string ( m_MaxDouble ) + " " " " + to_string ( m_MinDouble ) + " " " " " " " " ; InitializeSession ( 0 , scriptString , 5 ) ; vector < shared_ptr < SQLDOUBLE > > initParamValues = { make_shared < SQLDOUBLE > ( 0 ) , make_shared < SQLDOUBLE > ( 0 ) , make_shared < SQLDOUBLE > ( 0 ) , make_shared < SQLDOUBLE > ( 0 ) , nullptr } ; vector < SQLINTEGER > strLenOrInd = { 0 , 0 , 0 , 0 , SQL_NULL_DATA } ; vector < SQLSMALLINT > inputOutputTypes ( initParamValues . size ( ) , SQL_PARAM_INPUT_OUTPUT ) ; InitParam < SQLDOUBLE , Rcpp :: NumericVector , SQL_C_DOUBLE > ( 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 < SQLDOUBLE > > expectedParamValues = { make_shared < SQLDOUBLE > ( m_MaxDouble ) , make_shared < SQLDOUBLE > ( m_MinDouble ) , make_shared < SQLDOUBLE > ( 1.45e38 ) , make_shared < SQLDOUBLE > ( NAN ) , nullptr } ; vector < SQLINTEGER > expectedStrLenOrInd = { m_DoubleSize , m_DoubleSize , m_DoubleSize , SQL_NULL_DATA , SQL_NULL_DATA } ; GetOutputParam < SQLDOUBLE > ( expectedParamValues , expectedStrLenOrInd ) ; }
Name: GetDoubleOutputParamTest
Description:
Tests multiple double values.
Name : GetDoubleOutputParamTest Description : Tests multiple double 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(53), min FLOAT(53), a normal, NAN and nullptr DOUBLE values //