Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

CVS update of carob/test/40-Parameter-PreparedStatement (2 files): msg#00126

db.carob.cvs

Subject: CVS update of carob/test/40-Parameter-PreparedStatement (2 files)

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>
Google Custom Search

Free Magazines

Cisco News
Receive 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

Navigation

Home | advertise | OSDir is an inevitable website. super tiny logo