|
|
Choosing A Webhost: |
CVS update of carob/test/40-Parameter-PreparedStatement (2 files): msg#00126db.carob.cvs
Date: Wednesday, March 22, 2006 @ 19:24:41 Author: gilles Path: /cvsroot/carob/carob/test/40-Parameter-PreparedStatement Modified: TestParameterStatement.cpp (1.9 -> 1.10) TestParameterStatement.hpp (1.4 -> 1.5) Added testBigDecimal that writes and re-read special big decimal values to the DB This also tests big decimal contructors ----------------------------+ TestParameterStatement.cpp | 68 ++++++++++++++++++++++++++++++++++++++----- TestParameterStatement.hpp | 2 + 2 files changed, 63 insertions(+), 7 deletions(-) Index: carob/test/40-Parameter-PreparedStatement/TestParameterStatement.cpp diff -u carob/test/40-Parameter-PreparedStatement/TestParameterStatement.cpp:1.9 carob/test/40-Parameter-PreparedStatement/TestParameterStatement.cpp:1.10 --- carob/test/40-Parameter-PreparedStatement/TestParameterStatement.cpp:1.9 Fri Mar 3 16:54:13 2006 +++ carob/test/40-Parameter-PreparedStatement/TestParameterStatement.cpp Wed Mar 22 19:24:41 2006 @@ -19,19 +19,24 @@ * Contributor(s): Marc Herbert */ -#include <iostream> - -#include "Common.hpp" -#include "Connection.hpp" -#include "CarobException.hpp" -#include "DriverResultSet.hpp" #include "TestParameterStatement.hpp" -#include "RequestWithResultSetParameters.hpp" + #include "ResultSetMetaData.hpp" +#include "RequestWithResultSetParameters.hpp" +#include "BigDecimal.hpp" #include "ParameterStatement.hpp" +#include "DriverResultSet.hpp" + +#include "Connection.hpp" +#include "CarobException.hpp" +#include "Common.hpp" + +#include <iostream> +#include <limits> using std::wstring; using std::endl; +using std::numeric_limits; using namespace CarobNS; @@ -265,6 +270,52 @@ CPPUNIT_ASSERT(teststring == drs->getString(1)); // FIXME: replace by getBoolean() } +void TestParameterStatement::testBigDecimal() +{ + const std::wstring TABLE_TYPE(L"(bd DECIMAL(128))"); + const std::wstring TABLE_NAME(L"bigdecimaltest"); + + wstring fctName(L"TestParameterStatement::testBigDecimal"); + + createOrReplaceTable(connectionPtr, TABLE_NAME, TABLE_TYPE); + + ParameterStatement* pstmt = connectionPtr-> + createParameterStatement(wstring(L"INSERT into ") + TABLE_NAME + L" values (?)"); + + BigDecimal testVals[50]; + int nbTestVals = 0; + testVals[nbTestVals++] = BigDecimal(L"-123,456"); + testVals[nbTestVals++] = BigDecimal(L"123,456"); + testVals[nbTestVals++] = BigDecimal(-123456789); + testVals[nbTestVals++] = BigDecimal(123456789); + testVals[nbTestVals++] = BigDecimal(-123456789L); + testVals[nbTestVals++] = BigDecimal(123456789L); + testVals[nbTestVals++] = BigDecimal(-123456789LL); + testVals[nbTestVals++] = BigDecimal(123456789LL); + testVals[nbTestVals++] = BigDecimal(numeric_limits<int>::min()); + testVals[nbTestVals++] = BigDecimal(numeric_limits<int>::max()); + testVals[nbTestVals++] = BigDecimal(numeric_limits<long>::min()); + testVals[nbTestVals++] = BigDecimal(numeric_limits<long>::max()); + testVals[nbTestVals++] = BigDecimal(numeric_limits<long long>::min()); + testVals[nbTestVals++] = BigDecimal(numeric_limits<long long>::max()); + + for (int i=0; i<nbTestVals; i++) + { + logDebug(fctName, L"setting value " + static_cast<wstring>(testVals[i])); + pstmt->setBigDecimal(1, testVals[i]); + int uc = pstmt->executeUpdate(); + CPPUNIT_ASSERT(uc == 1); + } + Statement* stmt = connectionPtr-> createStatement(); + + DriverResultSet * drs = stmt->executeQuery(std::wstring(L"SELECT * from ") + TABLE_NAME); + for (int i=0; i<nbTestVals; i++) + { + CPPUNIT_ASSERT(drs->next()); + logDebug(fctName, L"testing with value " + static_cast<wstring>(testVals[i])); + CPPUNIT_ASSERT(drs->getBigDecimal(1) == testVals[i]); + } +} CppUnit::Test* TestParameterStatement::suite() { @@ -293,6 +344,9 @@ suiteOfTests->addTest(new CppUnit::TestCaller<TestParameterStatement>( "TestParameterStatement::testStrings", &TestParameterStatement::testStrings)); + suiteOfTests->addTest(new CppUnit::TestCaller<TestParameterStatement>( + "TestParameterStatement::testBigDecimal", + &TestParameterStatement::testBigDecimal)); return suiteOfTests; } Index: carob/test/40-Parameter-PreparedStatement/TestParameterStatement.hpp diff -u carob/test/40-Parameter-PreparedStatement/TestParameterStatement.hpp:1.4 carob/test/40-Parameter-PreparedStatement/TestParameterStatement.hpp:1.5 --- carob/test/40-Parameter-PreparedStatement/TestParameterStatement.hpp:1.4 Mon Feb 27 17:13:36 2006 +++ carob/test/40-Parameter-PreparedStatement/TestParameterStatement.hpp Wed Mar 22 19:24:41 2006 @@ -75,6 +75,8 @@ void testBoolean(); void testStrings(); + + void testBigDecimal(); }; #endif /*TESTPARAMETERSTATEMENT_H_*/
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of carob/test/30-ResultSet (TestBigDecimal.cpp), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of carob/src (Common.cpp), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of carob/test (CarobProtector.hpp), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Next by Thread: | CVS update of odbsequoia (odbc.ini), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home
| advertise | OSDir is
an inevitable website.
|