mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2026-11-15 00:07:08 +01:00
Update POCO library.
This commit is contained in:
1 parent
8d15f4b6e9
commit
233fc103f9
2521 files changed
+257092
-72789
No files matched your search
+80
-3
@@ -55,6 +55,7 @@ using Poco::Data::SQLChannel;
|
||||
using Poco::Data::LimitException;
|
||||
using Poco::Data::ConnectionFailedException;
|
||||
using Poco::Data::CLOB;
|
||||
using Poco::Data::BLOB;
|
||||
using Poco::Data::Date;
|
||||
using Poco::Data::Time;
|
||||
using Poco::Data::Transaction;
|
||||
@@ -463,7 +464,7 @@ void SQLiteTest::testInsertCharPointer()
|
||||
|
||||
pc = (const char*) std::calloc(9, sizeof(char));
|
||||
poco_check_ptr (pc);
|
||||
std::strncpy((char*) pc, "lastname", 8);
|
||||
std::strncpy((char*) pc, "lastname", 9);
|
||||
Statement stmt = (tmp << "INSERT INTO PERSON VALUES(:ln, :fn, :ad, :age)",
|
||||
bind(pc),
|
||||
bind("firstname"),
|
||||
@@ -1375,6 +1376,21 @@ void SQLiteTest::testEmptyDB()
|
||||
}
|
||||
|
||||
|
||||
void SQLiteTest::testNonexistingDB()
|
||||
{
|
||||
try
|
||||
{
|
||||
Session tmp (Poco::Data::SQLite::Connector::KEY, "foo/bar/nonexisting.db", 1);
|
||||
fail("non-existing DB must throw");
|
||||
}
|
||||
catch(ConnectionFailedException& ex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
fail("non-existing DB must throw ConnectionFailedException");
|
||||
}
|
||||
|
||||
|
||||
void SQLiteTest::testCLOB()
|
||||
{
|
||||
std::string lastName("lastname");
|
||||
@@ -1419,6 +1435,49 @@ void SQLiteTest::testCLOB()
|
||||
}
|
||||
|
||||
|
||||
void SQLiteTest::testBLOB()
|
||||
{
|
||||
std::string lastName("lastname");
|
||||
std::string firstName("firstname");
|
||||
std::string address("Address");
|
||||
Session tmp(Poco::Data::SQLite::Connector::KEY, "dummy.db");
|
||||
tmp << "DROP TABLE IF EXISTS Person", now;
|
||||
tmp << "CREATE TABLE IF NOT EXISTS Person (LastName VARCHAR(30), FirstName VARCHAR, Address VARCHAR, Image BLOB)", now;
|
||||
|
||||
struct DataStruct
|
||||
{
|
||||
int i = 0;
|
||||
Poco::Int64 i64 = 1;
|
||||
float f = 2.5;
|
||||
double d = 3.5;
|
||||
char c[16] = {0};
|
||||
};
|
||||
|
||||
DataStruct ds;
|
||||
strcpy(ds.c, "123456789ABCDEF");
|
||||
BLOB img(reinterpret_cast<unsigned char*>(&ds), sizeof(ds));
|
||||
assertTrue(img.size() == sizeof(ds));
|
||||
int count = 0;
|
||||
tmp << "INSERT INTO PERSON VALUES(:ln, :fn, :ad, :img)", use(lastName), use(firstName), use(address), use(img), now;
|
||||
tmp << "SELECT COUNT(*) FROM PERSON", into(count), now;
|
||||
assertTrue(count == 1);
|
||||
BLOB res;
|
||||
assertTrue(res.size() == 0);
|
||||
|
||||
tmp << "SELECT Image FROM Person WHERE LastName == :ln", bind("lastname"), into(res), now;
|
||||
assertTrue(res.size() == img.size());
|
||||
assertTrue(0 == std::memcmp(res.rawContent(), img.rawContent(), sizeof(img)));
|
||||
assertTrue(0 == std::memcmp(res.rawContent(), &ds, sizeof(ds)));
|
||||
DataStruct dsCopy;
|
||||
std::memcpy(&dsCopy, res.rawContent(), sizeof(dsCopy));
|
||||
assertTrue(ds.i == dsCopy.i);
|
||||
assertTrue(ds.i64 == dsCopy.i64);
|
||||
assertTrue(ds.f == dsCopy.f);
|
||||
assertTrue(ds.d == dsCopy.d);
|
||||
assertTrue(std::string(ds.c) == std::string(dsCopy.c));
|
||||
}
|
||||
|
||||
|
||||
void SQLiteTest::testTuple10()
|
||||
{
|
||||
Session tmp (Poco::Data::SQLite::Connector::KEY, "dummy.db");
|
||||
@@ -3161,7 +3220,8 @@ void SQLiteTest::testTransaction()
|
||||
std::string result;
|
||||
|
||||
session.setTransactionIsolation(Session::TRANSACTION_READ_COMMITTED);
|
||||
|
||||
session.setProperty(Poco::Data::SQLite::Utility::TRANSACTION_TYPE_PROPERTY_KEY,
|
||||
Poco::Data::SQLite::TransactionType::EXCLUSIVE);
|
||||
{
|
||||
Transaction trans(session);
|
||||
assertTrue (trans.isActive());
|
||||
@@ -3183,7 +3243,8 @@ void SQLiteTest::testTransaction()
|
||||
session << "SELECT count(*) FROM Person", into(count), now;
|
||||
assertTrue (0 == count);
|
||||
assertTrue (!session.isTransaction());
|
||||
|
||||
session.setProperty(Utility::TRANSACTION_TYPE_PROPERTY_KEY,
|
||||
Poco::Data::SQLite::TransactionType::IMMEDIATE);
|
||||
{
|
||||
Transaction trans(session);
|
||||
session << "INSERT INTO Person VALUES (?,?,?,?)", use(lastNames), use(firstNames), use(addresses), use(ages), now;
|
||||
@@ -3392,6 +3453,19 @@ void SQLiteTest::testIllegalFilePath()
|
||||
}
|
||||
}
|
||||
|
||||
void SQLiteTest::testTransactionTypeProperty()
|
||||
{
|
||||
try {
|
||||
using namespace Poco::Data::SQLite;
|
||||
|
||||
Session tmp(Connector::KEY, "dummy.db");
|
||||
tmp.setProperty(Utility::TRANSACTION_TYPE_PROPERTY_KEY, TransactionType::EXCLUSIVE);
|
||||
Poco::Any property = tmp.getProperty(Utility::TRANSACTION_TYPE_PROPERTY_KEY);
|
||||
TransactionType value = Poco::RefAnyCast<TransactionType>(property);
|
||||
assertTrue(value == TransactionType::EXCLUSIVE);
|
||||
} catch (Poco::Exception&) {}
|
||||
}
|
||||
|
||||
|
||||
void SQLiteTest::setUp()
|
||||
{
|
||||
@@ -3447,7 +3521,9 @@ CppUnit::Test* SQLiteTest::suite()
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testIllegalRange);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testSingleSelect);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testEmptyDB);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testNonexistingDB);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testCLOB);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testBLOB);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testTuple10);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testTupleVector10);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testTuple9);
|
||||
@@ -3495,6 +3571,7 @@ CppUnit::Test* SQLiteTest::suite()
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testTransactor);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testFTS3);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testIllegalFilePath);
|
||||
CppUnit_addTest(pSuite, SQLiteTest, testTransactionTypeProperty);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
@@ -74,8 +74,10 @@ public:
|
||||
void testIllegalRange();
|
||||
void testSingleSelect();
|
||||
void testEmptyDB();
|
||||
void testNonexistingDB();
|
||||
|
||||
void testCLOB();
|
||||
void testBLOB();
|
||||
|
||||
void testTuple1();
|
||||
void testTupleVector1();
|
||||
@@ -136,6 +138,7 @@ public:
|
||||
void testFTS3();
|
||||
|
||||
void testIllegalFilePath();
|
||||
void testTransactionTypeProperty();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ int wmain(int argc, wchar_t* argv[])
|
||||
std::wcstombs(buffer, argv[i], sizeof(buffer));
|
||||
args.push_back(std::string(buffer));
|
||||
}
|
||||
CppUnit::TestRunner runner;
|
||||
CppUnit::TestRunner runner;
|
||||
runner.addTest("SQLiteTestSuite", SQLiteTestSuite::suite());
|
||||
return runner.run(args) ? 0 : 1;
|
||||
}
|
||||
Reference in new issue
Block a user