Any and DynamicAny out and io

This commit is contained in:
Aleksandar Fabijanic
2007-10-31 21:48:22 +00:00
parent d248862406
commit a6aa475b55
14 changed files with 637 additions and 136 deletions

View File

@@ -35,6 +35,8 @@
#include "CppUnit/TestSuite.h"
#include "Poco/String.h"
#include "Poco/Format.h"
#include "Poco/Any.h"
#include "Poco/DynamicAny.h"
#include "Poco/Tuple.h"
#include "Poco/Exception.h"
#include "Poco/Data/Common.h"
@@ -56,6 +58,9 @@ using ODBC::StatementException;
using ODBC::StatementDiagnostics;
using Poco::format;
using Poco::Tuple;
using Poco::Any;
using Poco::AnyCast;
using Poco::DynamicAny;
using Poco::NotFoundException;
@@ -958,6 +963,77 @@ void ODBCDB2Test::testStoredProcedure()
}
void ODBCDB2Test::testStoredProcedureAny()
{
if (!_pSession) fail ("Test not available.");
for (int k = 0; k < 8;)
{
_pSession->setFeature("autoBind", bindValues[k]);
_pSession->setFeature("autoExtract", bindValues[k+1]);
Any i = 2;
Any j = 0;
*_pSession << "CREATE PROCEDURE storedProcedure(inParam INTEGER, OUT outParam INTEGER) "
"BEGIN "
" SET outParam = inParam*inParam; "
"END" , now;
*_pSession << "{call storedProcedure(?, ?)}", in(i), out(j), now;
assert(4 == AnyCast<int>(j));
*_pSession << "DROP PROCEDURE storedProcedure;", now;
*_pSession << "CREATE PROCEDURE storedProcedure(INOUT ioParam INTEGER) "
"BEGIN "
" SET ioParam = ioParam*ioParam; "
"END" , now;
i = 2;
*_pSession << "{call storedProcedure(?)}", io(i), now;
assert(4 == AnyCast<int>(i));
dropObject("PROCEDURE", "storedProcedure");
k += 2;
}
}
void ODBCDB2Test::testStoredProcedureDynamicAny()
{
if (!_pSession) fail ("Test not available.");
for (int k = 0; k < 8;)
{
_pSession->setFeature("autoBind", bindValues[k]);
DynamicAny i = 2;
DynamicAny j = 0;
*_pSession << "CREATE PROCEDURE storedProcedure(inParam INTEGER, OUT outParam INTEGER) "
"BEGIN "
" SET outParam = inParam*inParam; "
"END" , now;
*_pSession << "{call storedProcedure(?, ?)}", in(i), out(j), now;
assert(4 == j);
*_pSession << "DROP PROCEDURE storedProcedure;", now;
*_pSession << "CREATE PROCEDURE storedProcedure(INOUT ioParam INTEGER) "
"BEGIN "
" SET ioParam = ioParam*ioParam; "
"END" , now;
i = 2;
*_pSession << "{call storedProcedure(?)}", io(i), now;
assert(4 == i);
dropObject("PROCEDURE", "storedProcedure");
k += 2;
}
}
void ODBCDB2Test::testStoredFunction()
{
if (!_pSession) fail ("Test not available.");
@@ -1375,6 +1451,8 @@ CppUnit::Test* ODBCDB2Test::suite()
CppUnit_addTest(pSuite, ODBCDB2Test, testInternalExtraction);
CppUnit_addTest(pSuite, ODBCDB2Test, testInternalStorageType);
CppUnit_addTest(pSuite, ODBCDB2Test, testStoredProcedure);
CppUnit_addTest(pSuite, ODBCDB2Test, testStoredProcedureAny);
CppUnit_addTest(pSuite, ODBCDB2Test, testStoredProcedureDynamicAny);
CppUnit_addTest(pSuite, ODBCDB2Test, testStoredFunction);
CppUnit_addTest(pSuite, ODBCDB2Test, testNull);
CppUnit_addTest(pSuite, ODBCDB2Test, testRowIterator);