step, date, time

This commit is contained in:
Aleksandar Fabijanic
2007-11-10 23:21:28 +00:00
parent 95c5230389
commit fca08a18df
63 changed files with 2161 additions and 96 deletions

View File

@@ -132,6 +132,16 @@ void Binder::bind(std::size_t pos, const BLOB& val, Direction dir)
}
void Binder::bind(std::size_t pos, const Date& val, Direction dir)
{
}
void Binder::bind(std::size_t pos, const Time& val, Direction dir)
{
}
void Binder::bind(std::size_t pos, const DateTime& val, Direction dir)
{
}

View File

@@ -104,6 +104,12 @@ public:
void bind(std::size_t pos, const BLOB& val, Direction dir);
/// Binds a BLOB.
void bind(std::size_t pos, const Date& val, Direction dir);
/// Binds a Date.
void bind(std::size_t pos, const Time& val, Direction dir);
/// Binds a Time.
void bind(std::size_t pos, const DateTime& val, Direction dir);
/// Binds a DateTime.

View File

@@ -38,9 +38,12 @@
#include "Poco/Data/BLOBStream.h"
#include "Poco/Data/MetaColumn.h"
#include "Poco/Data/Column.h"
#include "Poco/Data/Date.h"
#include "Poco/Data/Time.h"
#include "Connector.h"
#include "Poco/BinaryReader.h"
#include "Poco/BinaryWriter.h"
#include "Poco/DateTime.h"
#include "Poco/Types.h"
#include "Poco/Exception.h"
#include <cstring>
@@ -56,9 +59,11 @@ using Poco::BinaryWriter;
using Poco::UInt32;
using Poco::Int64;
using Poco::UInt64;
using Poco::DateTime;
using Poco::InvalidAccessException;
using Poco::RangeException;
using Poco::NotFoundException;
using Poco::InvalidArgumentException;
DataTest::DataTest(const std::string& name): CppUnit::TestCase(name)
@@ -1003,6 +1008,74 @@ void DataTest::testRowFormat()
}
void DataTest::testDateAndTime()
{
DateTime dt;
Date d(dt);
Time t(dt);
assert (dt.year() == d.year());
assert (dt.month() == d.month());
assert (dt.day() == d.day());
assert (dt.hour() == t.hour());
assert (dt.minute() == t.minute());
assert (dt.second() == t.second());
Date d1(2007, 6, 15);
d1.assign(d.year() - 1, d.month(), d.day());
assert (d1 < d); assert (d1 != d);
d1.assign(d.year(), d.month() - 1, d.day());
assert (d1 < d); assert (d1 != d);
d1.assign(d.year(), d.month(), d.day() - 1);
assert (d1 < d); assert (d1 != d);
d1.assign(d.year() + 1, d.month(), d.day());
assert (d1 > d); assert (d1 != d);
d1.assign(d.year(), d.month() + 1, d.day());
assert (d1 > d); assert (d1 != d);
d1.assign(d.year(), d.month(), d.day() + 1);
assert (d1 > d); assert (d1 != d);
d1.assign(d.year(), d.month(), d.day());
assert (d1 == d);
try { d1.assign(-1, 1, 1); fail ("must fail"); }
catch (InvalidArgumentException&) { }
try { d1.assign(1, 0, 1); fail ("must fail"); }
catch (InvalidArgumentException&) { }
try { d1.assign(1, 1, 0); fail ("must fail"); }
catch (InvalidArgumentException&) { }
Time t1(12, 30, 15);
t1.assign(t.hour() - 1, t.minute(), t.second());
assert (t1 < t); assert (t1 != t);
t1.assign(t.hour(), t.minute() - 1, t.second());
assert (t1 < t); assert (t1 != t);
t1.assign(t.hour(), t.minute(), t.second() - 1);
assert (t1 < t); assert (t1 != t);
t1.assign(t.hour() + 1, t.minute(), t.second());
assert (t1 > t); assert (t1 != t);
t1.assign(t.hour(), t.minute() + 1, t.second());
assert (t1 > t); assert (t1 != t);
t1.assign(t.hour(), t.minute(), t.second() + 1);
assert (t1 > t); assert (t1 != t);
t1.assign(t.hour(), t.minute(), t.second());
assert (t1 == t);
try { t1.assign(-1, 0, 0); fail ("must fail"); }
catch (InvalidArgumentException&) { }
try { t1.assign(0, -1, 0); fail ("must fail"); }
catch (InvalidArgumentException&) { }
try { t1.assign(0, 0, -1); fail ("must fail"); }
catch (InvalidArgumentException&) { }
d1 = dt;
assert (d1 == dt);
t1 = dt;
assert (t1 == dt);
}
void DataTest::setUp()
{
}
@@ -1029,6 +1102,7 @@ CppUnit::Test* DataTest::suite()
CppUnit_addTest(pSuite, DataTest, testRow);
CppUnit_addTest(pSuite, DataTest, testRowSort);
CppUnit_addTest(pSuite, DataTest, testRowFormat);
CppUnit_addTest(pSuite, DataTest, testDateAndTime);
return pSuite;
}

View File

@@ -61,6 +61,7 @@ public:
void testRow();
void testRowSort();
void testRowFormat();
void testDateAndTime();
void setUp();
void tearDown();

View File

@@ -155,6 +155,19 @@ bool Extractor::extract(std::size_t pos, Poco::Data::BLOB& val)
return true;
}
bool Extractor::extract(std::size_t pos, Poco::Data::Date& val)
{
return true;
}
bool Extractor::extract(std::size_t pos, Poco::Data::Time& val)
{
return true;
}
bool Extractor::extract(std::size_t pos, Poco::DateTime& val)
{
return true;

View File

@@ -107,6 +107,12 @@ public:
bool extract(std::size_t pos, Poco::Data::BLOB& val);
/// Extracts a BLOB.
bool extract(std::size_t pos, Date& val);
/// Extracts a Date.
bool extract(std::size_t pos, Time& val);
/// Extracts a Time.
bool extract(std::size_t pos, Poco::DateTime& val);
/// Extracts a DateTime.

View File

@@ -127,6 +127,16 @@ void Preparation::prepare(std::size_t pos, const Poco::Data::BLOB&)
}
void Preparation::prepare(std::size_t pos, const Poco::Data::Date&)
{
}
void Preparation::prepare(std::size_t pos, const Poco::Data::Time&)
{
}
void Preparation::prepare(std::size_t pos, const Poco::DateTime&)
{
}

View File

@@ -102,6 +102,12 @@ public:
void prepare(std::size_t pos, const Poco::Data::BLOB&);
/// Prepares a BLOB.
void prepare(std::size_t pos, const Poco::Data::Date&);
/// Prepares a Date.
void prepare(std::size_t pos, const Poco::Data::Time&);
/// Prepares a Time.
void prepare(std::size_t pos, const Poco::DateTime&);
/// Prepares a DateTime.

View File

@@ -103,7 +103,7 @@ bool TestStatementImpl::hasNext()
}
void TestStatementImpl::next()
Poco::UInt32 TestStatementImpl::next()
{
Poco::Data::AbstractExtractionVec::iterator it = extractions().begin();
Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end();
@@ -113,6 +113,8 @@ void TestStatementImpl::next()
(*it)->extract(pos);
pos += (*it)->numOfColumnsHandled();
}
return 1u;
}

View File

@@ -72,8 +72,8 @@ protected:
bool hasNext();
/// Returns true if a call to next() will return data.
void next();
/// Retrieves the next row from the resultset.
Poco::UInt32 next();
/// Retrieves the next row or set of rows from the resultset.
/// Will throw, if the resultset is empty.
bool canBind() const;