Date: Thursday, March 9, 2006 @ 10:47:36
Author: gilles
Path: /cvsroot/carob/carob/test/30-ResultSet
Modified: TestBigDecimal.cpp (1.3 -> 1.4) TestBigDecimal.hpp (1.1 -> 1.2)
Added tests on floats and doubles
--------------------+
TestBigDecimal.cpp | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++-
TestBigDecimal.hpp | 14 +++++
2 files changed, 132 insertions(+), 3 deletions(-)
Index: carob/test/30-ResultSet/TestBigDecimal.cpp
diff -u carob/test/30-ResultSet/TestBigDecimal.cpp:1.3
carob/test/30-ResultSet/TestBigDecimal.cpp:1.4
--- carob/test/30-ResultSet/TestBigDecimal.cpp:1.3 Tue Mar 7 12:48:25 2006
+++ carob/test/30-ResultSet/TestBigDecimal.cpp Thu Mar 9 10:47:36 2006
@@ -63,6 +63,22 @@
L"UPDATE product SET cost = " + toWString(numeric_limits<long
long>::min()) + L" WHERE id=" + toWString(id++));
statementPtr->executeUpdate(
L"UPDATE product SET cost = " + toWString(numeric_limits<long
long>::max()) + L" WHERE id= " + toWString(id++));
+// statementPtr->executeUpdate(
+// L"UPDATE product SET cost = " +
toWString(numeric_limits<float>::min()) + L" WHERE id=" + toWString(id++));
+ statementPtr->executeUpdate(
+ L"UPDATE product SET cost =
0.000000000000000000000000000000000000011754943508222875079687365372222456778186655567720875215087517062784172594547271728515625
WHERE id=" + toWString(id++));
+// statementPtr->executeUpdate(
+// L"UPDATE product SET cost = " +
toWString(numeric_limits<float>::max()) + L" WHERE id= " + toWString(id++));
+ statementPtr->executeUpdate(
+ L"UPDATE product SET cost =
340282346638528859811704183484516925440.000000 WHERE id= " + toWString(id++));
+// statementPtr->executeUpdate(
+// L"UPDATE product SET cost = " +
toWString(numeric_limits<double>::min()) + L" WHERE id=" + toWString(id++));
+ statementPtr->executeUpdate(
+ L"UPDATE product SET cost =
0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002225073858507201383090232717332404064219215980462331830553327416887204434813918195854283159012511020564067339731035811005152434161553460108856012385377718821130777993532002330479610147442583636071921565046942503734208375250806650616658158948720491179968591639648500635908770118304874799780887753749949451580451605050915399856582470818645113537935804992115981085766051992433352114352390148795699609591288891602992641511063466313393663477586513029371762047325631781485664350872122828637642044846811407613911477062801689853244110024161447421618567166150540154285084716752901903161322778896729707373123334086988983175067838846926092773977972858659654941091369095406136467568702398678315290680984617210924625396728515625
WHERE id=" + toWString(id++));
+// statementPtr->executeUpdate(
+// L"UPDATE product SET cost = " +
toWString(numeric_limits<double>::max()) + L" WHERE id= " + toWString(id++));
+ statementPtr->executeUpdate(
+ L"UPDATE product SET cost =
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000
WHERE id= " + toWString(id++));
statementPtr->executeUpdate(
L"UPDATE product SET cost =
-123456789012345678901234567890.123456789012345678901234567890 WHERE id=" +
toWString(id++));
statementPtr->executeUpdate(
@@ -103,6 +119,18 @@
logInfo(fctName, toWString(numeric_limits<long long>::max()) + L" -
getAsString=" + drsPtr->getAsString(3));
CPPUNIT_ASSERT(drsPtr->getAsString(3) == toWString(numeric_limits<long
long>::max()));
drsPtr->next();
+// logInfo(fctName, toWString(numeric_limits<float>::min()) + L" -
getAsString=" + drsPtr->getAsString(3));
+// CPPUNIT_ASSERT(drsPtr->getAsString(3) ==
toWString(numeric_limits<float>::min()));
+ drsPtr->next();
+// logInfo(fctName, toWString(numeric_limits<float>::max()) + L" -
getAsString=" + drsPtr->getAsString(3));
+// CPPUNIT_ASSERT(drsPtr->getAsString(3) ==
toWString(numeric_limits<float>::max()));
+ drsPtr->next();
+// logInfo(fctName, toWString(numeric_limits<double>::min()) + L" -
getAsString=" + drsPtr->getAsString(3));
+// CPPUNIT_ASSERT(drsPtr->getAsString(3) ==
toWString(numeric_limits<double>::min()));
+ drsPtr->next();
+// logInfo(fctName, toWString(numeric_limits<double>::max()) + L" -
getAsString=" + drsPtr->getAsString(3));
+// CPPUNIT_ASSERT(drsPtr->getAsString(3) ==
toWString(numeric_limits<double>::max()));
+ drsPtr->next();
logInfo(fctName, wstring(L"-123456789012345678901234567890") +
use_facet<numpunct<wchar_t> >(std::locale()).decimal_point() +
L"123456789012345678901234567890 - getAsString=" + drsPtr->getAsString(3));
CPPUNIT_ASSERT(drsPtr->getAsString(3) == L"-123456789012345678901234567890"
+ fromString(localeconv()->decimal_point) + L"123456789012345678901234567890");
drsPtr->next();
@@ -188,9 +216,12 @@
logInfo(fctName, toWString(numeric_limits<long long>::max()) + L" -
getAsInt64=" + toWString(drsPtr->getAsInt64(3)));
CPPUNIT_ASSERT(drsPtr->getAsInt64(3) == numeric_limits<long long>::max());
drsPtr->next();
+ logInfo(fctName, L"0<number<1 - getAsInt64="+drsPtr->getAsString(3));
+ CPPUNIT_ASSERT(drsPtr->getAsInt64(3) == 0);
+ drsPtr->next();
try
{
- logInfo(fctName, L"Trying getAsInt64 on a too big number
="+drsPtr->getAsString(3));
+ logInfo(fctName, L"Trying getAsInt64 on a too big
number="+drsPtr->getAsString(3));
drsPtr->getAsInt64(3);
CPPUNIT_ASSERT(false);
}
@@ -202,6 +233,88 @@
connectionPtr->deleteStatement(statementPtr);
}
+//TODO test this deeper
+void TestBigDecimal::testGetAsFloat()
+{
+ wstring fctName(L"TestBigDecimal::testGetAsFloat");
+ Statement* statementPtr = NULL;
+ statementPtr = connectionPtr->createStatement();
+ DriverResultSet* drsPtr = statementPtr->executeQuery(L"SELECT * FROM
product");
+ drsPtr->next();
+ logInfo(fctName, L"0 - getAsFloat=" + toWString(drsPtr->getAsFloat(3)));
+ CPPUNIT_ASSERT(drsPtr->getAsFloat(3) == 0);
+ drsPtr->next();
+ logInfo(fctName, L"-1 - getAsFloat=" + toWString(drsPtr->getAsFloat(3)));
+ CPPUNIT_ASSERT(drsPtr->getAsFloat(3) == -1);
+ drsPtr->next();
+ logInfo(fctName, L"1 - getAsFloat=" + toWString(drsPtr->getAsFloat(3)));
+ CPPUNIT_ASSERT(drsPtr->getAsFloat(3) == 1);
+ drsPtr->next();
+ // -12.34);
+ drsPtr->next();
+ // 12.34);
+ drsPtr->next();
+ // min int
+ drsPtr->next();
+ // max int
+ drsPtr->next();
+ // min long
+ drsPtr->next();
+ // max long
+ drsPtr->next();
+ logInfo(fctName, toWString(numeric_limits<float>::min()) + L" - getAsFloat="
+ toWString(drsPtr->getAsFloat(3)));
+ CPPUNIT_ASSERT(drsPtr->getAsFloat(3) == numeric_limits<float>::min());
+ drsPtr->next();
+ logInfo(fctName, toWString(numeric_limits<float>::max()) + L" - getAsFloat="
+ toWString(drsPtr->getAsFloat(3)));
+ CPPUNIT_ASSERT(drsPtr->getAsFloat(3) == numeric_limits<float>::max());
+ connectionPtr->deleteStatement(statementPtr);
+}
+
+//TODO test this deeper
+void TestBigDecimal::testGetAsDouble()
+{
+ wstring fctName(L"TestBigDecimal::testGetAsDouble");
+ Statement* statementPtr = NULL;
+ statementPtr = connectionPtr->createStatement();
+ DriverResultSet* drsPtr = statementPtr->executeQuery(L"SELECT * FROM
product");
+ drsPtr->next();
+ logInfo(fctName, L"0 - getAsDouble=" + toWString(drsPtr->getAsDouble(3)));
+ CPPUNIT_ASSERT(drsPtr->getAsDouble(3) == 0);
+ drsPtr->next();
+ logInfo(fctName, L"-1 - getAsDouble=" + toWString(drsPtr->getAsDouble(3)));
+ CPPUNIT_ASSERT(drsPtr->getAsDouble(3) == -1);
+ drsPtr->next();
+ logInfo(fctName, L"1 - getAsDouble=" + toWString(drsPtr->getAsDouble(3)));
+ CPPUNIT_ASSERT(drsPtr->getAsDouble(3) == 1);
+ drsPtr->next();
+ logInfo(fctName, L"-12.34 - getAsDouble=" +
toWString(drsPtr->getAsDouble(3)));
+ CPPUNIT_ASSERT(drsPtr->getAsDouble(3) == -12.34);
+ drsPtr->next();
+ logInfo(fctName, L"12.34 - getAsDouble=" +
toWString(drsPtr->getAsDouble(3)));
+ CPPUNIT_ASSERT(drsPtr->getAsDouble(3) == 12.34);
+ drsPtr->next();
+ logInfo(fctName, toWString(numeric_limits<int>::min()) + L" - getAsDouble="
+ toWString(drsPtr->getAsDouble(3)));
+ CPPUNIT_ASSERT(drsPtr->getAsDouble(3) == numeric_limits<int>::min());
+ drsPtr->next();
+ logInfo(fctName, toWString(numeric_limits<int>::max()) + L" - getAsDouble="
+ toWString(drsPtr->getAsDouble(3)));
+ CPPUNIT_ASSERT(drsPtr->getAsDouble(3) == numeric_limits<int>::max());
+ drsPtr->next();
+ drsPtr->next(); //skip longs
+ drsPtr->next();
+ logInfo(fctName, toWString(numeric_limits<float>::min()) + L" -
getAsDouble=" + toWString(drsPtr->getAsDouble(3)));
+ CPPUNIT_ASSERT(drsPtr->getAsDouble(3) == numeric_limits<float>::min());
+ drsPtr->next();
+ logInfo(fctName, toWString(numeric_limits<float>::max()) + L" -
getAsDouble=" + toWString(drsPtr->getAsDouble(3)));
+ CPPUNIT_ASSERT(drsPtr->getAsDouble(3) == numeric_limits<float>::max());
+ drsPtr->next();
+ logInfo(fctName, toWString(numeric_limits<double>::min()) + L" -
getAsDouble=" + toWString(drsPtr->getAsDouble(3)));
+ CPPUNIT_ASSERT(drsPtr->getAsDouble(3) == numeric_limits<double>::min());
+ drsPtr->next();
+ logInfo(fctName, toWString(numeric_limits<double>::max()) + L" -
getAsDouble=" + toWString(drsPtr->getAsDouble(3)));
+ CPPUNIT_ASSERT(drsPtr->getAsDouble(3) == numeric_limits<double>::max());
+ connectionPtr->deleteStatement(statementPtr);
+}
+
CppUnit::Test* TestBigDecimal::suite()
{
CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "TestBigDecimal"
);
@@ -214,6 +327,12 @@
suiteOfTests->addTest(new CppUnit::TestCaller<TestBigDecimal>(
"TestBigDecimal::testGetAsInt64",
&TestBigDecimal::testGetAsInt64));
+ suiteOfTests->addTest(new CppUnit::TestCaller<TestBigDecimal>(
+ "TestBigDecimal::testGetAsFloat",
+ &TestBigDecimal::testGetAsFloat));
+ suiteOfTests->addTest(new CppUnit::TestCaller<TestBigDecimal>(
+ "TestBigDecimal::testGetAsDouble",
+ &TestBigDecimal::testGetAsDouble));
return suiteOfTests;
}
Index: carob/test/30-ResultSet/TestBigDecimal.hpp
diff -u carob/test/30-ResultSet/TestBigDecimal.hpp:1.1
carob/test/30-ResultSet/TestBigDecimal.hpp:1.2
--- carob/test/30-ResultSet/TestBigDecimal.hpp:1.1 Fri Mar 3 18:21:26 2006
+++ carob/test/30-ResultSet/TestBigDecimal.hpp Thu Mar 9 10:47:36 2006
@@ -52,10 +52,20 @@
*/
void testGetAsInt();
/**
- * Read big decimal values using getAsInt64() and checks that the long read
- * is the expected one
+ * Read big decimal values using getAsInt64() and checks that the long long
+ * read is the expected one
*/
void testGetAsInt64();
+ /**
+ * Read big decimal values using getAsFloat() and checks that the double read
+ * is the expected one
+ */
+ void testGetAsFloat();
+ /**
+ * Read big decimal values using getAsDouble() and checks that the double
read
+ * is the expected one
+ */
+ void testGetAsDouble();
};
#endif /*TESTBIGDECIMAL_H_*/
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits