mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-24 17:30:44 +02:00
- use() takes reference now
- bind() for constants - Statement: allow for easier external binding supply
This commit is contained in:
@@ -1098,12 +1098,21 @@ void DataTest::testDateAndTime()
|
||||
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);
|
||||
if (t.hour() < 23)
|
||||
{
|
||||
t1.assign(t.hour() + 1, t.minute(), t.second());
|
||||
assert (t1 > t); assert (t1 != t);
|
||||
}
|
||||
if (t.minute() < 59)
|
||||
{
|
||||
t1.assign(t.hour(), t.minute() + 1, t.second());
|
||||
assert (t1 > t); assert (t1 != t);
|
||||
}
|
||||
if (t.second() < 59)
|
||||
{
|
||||
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);
|
||||
|
||||
@@ -1122,6 +1131,55 @@ void DataTest::testDateAndTime()
|
||||
}
|
||||
|
||||
|
||||
void DataTest::testExternalBindingAndExtraction()
|
||||
{
|
||||
AbstractExtractionVecVec extractionVec;
|
||||
AbstractExtractionVec extraction;
|
||||
AbstractBindingVec binding;
|
||||
|
||||
Session tmp (Poco::Data::Test::Connector::KEY, "dummy.db");
|
||||
|
||||
int i;
|
||||
AbstractExtraction* pExt1 = into(i);
|
||||
AbstractExtraction* pExt2 = into(i);
|
||||
assert (1 == pExt1->referenceCount());
|
||||
assert (1 == pExt2->referenceCount());
|
||||
{
|
||||
Statement stmt(tmp);
|
||||
stmt.addExtract(pExt1); // retain external ownership in addition to giving it to statement
|
||||
assert (2 == pExt1->referenceCount());
|
||||
stmt.addExtract(pExt2, false); // give ownership to statement
|
||||
assert (1 == pExt2->referenceCount());
|
||||
}
|
||||
assert (1 == pExt1->referenceCount()); delete pExt1;
|
||||
// pExt2 does not exist any more
|
||||
|
||||
AbstractBinding* pBind1 = use(i, "mybind1");
|
||||
AbstractBinding* pBind2 = use(i, "mybind2");
|
||||
AbstractBinding* pBind3 = use(i, "mybind3");
|
||||
assert (1 == pBind1->referenceCount());
|
||||
assert (1 == pBind2->referenceCount());
|
||||
assert (1 == pBind3->referenceCount());
|
||||
{
|
||||
Statement stmt(tmp);
|
||||
stmt.addBind(pBind1); // retain external ownership in addition to giving it to statement
|
||||
assert (2 == pBind1->referenceCount());
|
||||
stmt.addBind(pBind2, false);// give ownership to statement
|
||||
assert (1 == pBind2->referenceCount());
|
||||
stmt.addBind(pBind3);// give ownership to statement
|
||||
assert (2 == pBind3->referenceCount());
|
||||
stmt.removeBind(pBind3->name());// take ownership from statement
|
||||
assert (1 == pBind3->referenceCount());
|
||||
|
||||
try { stmt.removeBind("a bad name"); fail("must fail"); }
|
||||
catch (NotFoundException&) { }
|
||||
}
|
||||
assert (1 == pBind1->referenceCount()); delete pBind1;
|
||||
// pBind2 does not exist any more
|
||||
assert (1 == pBind3->referenceCount()); delete pBind3;
|
||||
}
|
||||
|
||||
|
||||
void DataTest::setUp()
|
||||
{
|
||||
}
|
||||
@@ -1150,6 +1208,7 @@ CppUnit::Test* DataTest::suite()
|
||||
CppUnit_addTest(pSuite, DataTest, testRowSort);
|
||||
CppUnit_addTest(pSuite, DataTest, testRowFormat);
|
||||
CppUnit_addTest(pSuite, DataTest, testDateAndTime);
|
||||
CppUnit_addTest(pSuite, DataTest, testExternalBindingAndExtraction);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user