language-extensions/R/test/src/RExtensionApiTests.cpp
//----------------------------------------------------------------------------------------------
// Name: RExtensionApiTest::DoInit
//
// Description:
//  Does Init where embedded R is initialized - can be called only once in the test suite.
//  Testing if Init api is implemented correctly.
//
:DoInit
Description:
Does Init where embedded R is initialized - can be called only once in the test suite.
Testing if Init api is implemented correctly.
: DoInit Description : Does Init where embedded R is initialized - can be called only once in the test suite . Testing if Init api is implemented correctly .
void RExtensionApiTests::DoInit()
	{
		std::cout << "Calling Init.\n";
		SQLRETURN result = SQL_ERROR;
		const string cmdLine = "dummyInputScript --no-save";
		int paramsLength = strlen(cmdLine.c_str());
		unique_ptr<SQLCHAR[]> extensionParams = make_unique<SQLCHAR[]>(paramsLength);
		memcpy(extensionParams.get(), cmdLine.c_str(), paramsLength);
		SQLCHAR *extensionPath = static_cast<SQLCHAR *>(
			static_cast<void *>(const_cast<char *>(sm_RHomePath.c_str())));
		SQLCHAR* publiclibraryPath = static_cast<SQLCHAR *>(
			static_cast<void *>(const_cast<char *>(sm_publicLibraryPath.c_str())));
		SQLCHAR* privateLibraryPath = static_cast<SQLCHAR *>(
			static_cast<void *>(const_cast<char *>(sm_privateLibraryPath.c_str())));
		result = (*sm_initFuncPtr)(
			extensionParams.get(),
			paramsLength,
			extensionPath,
			sm_RHomePath.length(),
			publiclibraryPath,
			sm_publicLibraryPath.length(),
			privateLibraryPath,
			sm_privateLibraryPath.length());
		ASSERT_EQ(result, SQL_SUCCESS);
	}
void RExtensionApiTests :: DoInit ( ) { std :: cout << " \n " ; SQLRETURN result = SQL_ERROR ; const string cmdLine = " " ; int paramsLength = strlen ( cmdLine . c_str ( ) ) ; unique_ptr < SQLCHAR [ ] > extensionParams = make_unique < SQLCHAR [ ] > ( paramsLength ) ; memcpy ( extensionParams . get ( ) , cmdLine . c_str ( ) , paramsLength ) ; SQLCHAR * extensionPath = static_cast < SQLCHAR * > ( static_cast < void * > ( const_cast < char * > ( sm_RHomePath . c_str ( ) ) ) ) ; SQLCHAR * publiclibraryPath = static_cast < SQLCHAR * > ( static_cast < void * > ( const_cast < char * > ( sm_publicLibraryPath . c_str ( ) ) ) ) ; SQLCHAR * privateLibraryPath = static_cast < SQLCHAR * > ( static_cast < void * > ( const_cast < char * > ( sm_privateLibraryPath . c_str ( ) ) ) ) ; result = ( * sm_initFuncPtr ) ( extensionParams . get ( ) , paramsLength , extensionPath , sm_RHomePath . length ( ) , publiclibraryPath , sm_publicLibraryPath . length ( ) , privateLibraryPath , sm_privateLibraryPath . length ( ) ) ; ASSERT_EQ ( result , SQL_SUCCESS ) ; }
Name: RExtensionApiTest::DoInit
Description:
Does Init where embedded R is initialized - can be called only once in the test suite.
Name : RExtensionApiTest :: DoInit Description : Does Init where embedded R is initialized - can be called only once in the test suite .