Date: Friday, April 7, 2006 @ 17:24:31
Author: gilles
Path: /cvsroot/carob/carob/test/40-Parameter-PreparedStatement
Modified: TestParameterStatement.cpp (1.11 -> 1.12)
TestParameterStatement.hpp (1.6 -> 1.7)
Implemented setNull test corresponding to CAROB-92 - will fail until bug
fixed...
----------------------------+
TestParameterStatement.cpp | 32 ++++++++++++++++++++++++++++++++
TestParameterStatement.hpp | 4 ++++
2 files changed, 36 insertions(+)
Index: carob/test/40-Parameter-PreparedStatement/TestParameterStatement.cpp
diff -u
carob/test/40-Parameter-PreparedStatement/TestParameterStatement.cpp:1.11
carob/test/40-Parameter-PreparedStatement/TestParameterStatement.cpp:1.12
--- carob/test/40-Parameter-PreparedStatement/TestParameterStatement.cpp:1.11
Thu Mar 23 15:30:36 2006
+++ carob/test/40-Parameter-PreparedStatement/TestParameterStatement.cpp
Fri Apr 7 17:24:31 2006
@@ -318,6 +318,35 @@
}
}
+void TestParameterStatement::testSetNull()
+{
+ const std::wstring TABLE_TYPE(L"(c1 smallint, c2 smallint)");
+ const std::wstring TABLE_NAME(L"testSetNull");
+
+ wstring fctName(L"TestParameterStatement::testSetNull");
+
+ createOrReplaceTable(connectionPtr, TABLE_NAME, TABLE_TYPE);
+
+ ParameterStatement* pstmt = connectionPtr->
+ createParameterStatement(wstring(L"INSERT into ") + TABLE_NAME + L" values
(?, ?)");
+ pstmt->setInt(1, -125);
+ pstmt->setNull(2);
+ pstmt->execute();
+ Statement* stmt = connectionPtr-> createStatement();
+ DriverResultSet* drs = stmt->executeQuery(std::wstring(L"SELECT * from ") +
TABLE_NAME);
+ CPPUNIT_ASSERT(drs->next());
+ try
+ {
+ logDebug(fctName, L"Trying to get null value - should throw an exception");
+ drs->getInt32(2);
+ CPPUNIT_ASSERT(false);
+ }
+ catch (NullValueException nve)
+ {
+ logDebug(fctName, L"NullValueException caught - this is ok");
+ }
+}
+
CppUnit::Test* TestParameterStatement::suite()
{
CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite(
"TestParameterStatement" );
@@ -348,6 +377,9 @@
suiteOfTests->addTest(new CppUnit::TestCaller<TestParameterStatement>(
"TestParameterStatement::testBigDecimal",
&TestParameterStatement::testBigDecimal));
+ suiteOfTests->addTest(new CppUnit::TestCaller<TestParameterStatement>(
+ "TestParameterStatement::testSetNull",
+ &TestParameterStatement::testSetNull));
return suiteOfTests;
}
Index: carob/test/40-Parameter-PreparedStatement/TestParameterStatement.hpp
diff -u
carob/test/40-Parameter-PreparedStatement/TestParameterStatement.hpp:1.6
carob/test/40-Parameter-PreparedStatement/TestParameterStatement.hpp:1.7
--- carob/test/40-Parameter-PreparedStatement/TestParameterStatement.hpp:1.6
Thu Mar 23 17:10:04 2006
+++ carob/test/40-Parameter-PreparedStatement/TestParameterStatement.hpp
Fri Apr 7 17:24:31 2006
@@ -86,6 +86,10 @@
* statement and checking that the value read back is the original one.
*/
void testBigDecimal();
+ /**
+ * Tests setNull function
+ */
+ void testSetNull();
};
#endif /*TESTPARAMETERSTATEMENT_H_*/
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits