Update POCO library.

This commit is contained in:
Sandu Liviu Catalin committed 2023-03-23 20:19:11 +02:00
1 parent 8d15f4b6e9
commit 233fc103f9
2521 files changed
+257092 -72789

No files matched your search

+60
View File
@@ -422,6 +422,8 @@ void MySQLTest::testDateTime()
_pExecutor->date();
recreatePersonTimeTable();
_pExecutor->time();
recreatePersonTimestampTable();
_pExecutor->timestamp();
}
@@ -469,6 +471,32 @@ void MySQLTest::testBLOBStmt()
}
void MySQLTest::testLongBLOB()
{
if (!_pSession) fail ("Test not available.");
recreatePersonLongBLOBTable();
_pExecutor->longBlob();
}
void MySQLTest::testLongTEXT()
{
if (!_pSession) fail ("Test not available.");
recreatePersonLongBLOBTable();
_pExecutor->longText();
}
#ifdef POCO_MYSQL_JSON
void MySQLTest::testJSON()
{
if (!_pSession) fail("Test not available.");
recreatePersonJSONTable();
_pExecutor->json();
}
#endif
void MySQLTest::testUnsignedInts()
{
if (!_pSession) fail ("Test not available.");
@@ -752,6 +780,33 @@ void MySQLTest::recreatePersonTimeTable()
}
void MySQLTest::recreatePersonTimestampTable()
{
dropTable("Person");
try { *_pSession << "CREATE TABLE Person (LastName VARCHAR(30), FirstName VARCHAR(30), Address VARCHAR(30), Birthday TIMESTAMP(6))", now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail ("recreatePersonTimestampTable()"); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail ("recreatePersonTimestampTable()"); }
}
void MySQLTest::recreatePersonLongBLOBTable()
{
dropTable("Person");
try { *_pSession << "CREATE TABLE Person (LastName VARCHAR(30), FirstName VARCHAR(30), Address VARCHAR(30), Biography LONGTEXT)", now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail ("recreatePersonLongBLOBTable()"); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail ("recreatePersonLongBLOBTable()"); }
}
#ifdef POCO_MYSQL_JSON
void MySQLTest::recreatePersonJSONTable()
{
dropTable("Person");
try { *_pSession << "CREATE TABLE Person (LastName VARCHAR(30), FirstName VARCHAR(30), Address VARCHAR(30), Biography JSON)", now; }
catch (ConnectionException& ce) { std::cout << ce.displayText() << std::endl; fail("recreatePersonJSONTable()"); }
catch (StatementException& se) { std::cout << se.displayText() << std::endl; fail("recreatePersonJSONTable()"); }
}
#endif
void MySQLTest::recreateIntsTable()
{
dropTable("Strings");
@@ -919,6 +974,11 @@ CppUnit::Test* MySQLTest::suite()
CppUnit_addTest(pSuite, MySQLTest, testDateTime);
//CppUnit_addTest(pSuite, MySQLTest, testBLOB);
CppUnit_addTest(pSuite, MySQLTest, testBLOBStmt);
CppUnit_addTest(pSuite, MySQLTest, testLongBLOB);
CppUnit_addTest(pSuite, MySQLTest, testLongTEXT);
#ifdef POCO_MYSQL_JSON
CppUnit_addTest(pSuite, MySQLTest, testJSON);
#endif
CppUnit_addTest(pSuite, MySQLTest, testUnsignedInts);
CppUnit_addTest(pSuite, MySQLTest, testFloat);
CppUnit_addTest(pSuite, MySQLTest, testDouble);
+10
View File
@@ -79,6 +79,11 @@ public:
void testDateTime();
void testBLOB();
void testBLOBStmt();
void testLongBLOB();
void testLongTEXT();
#ifdef POCO_MYSQL_JSON
void testJSON();
#endif
void testUnsignedInts();
void testFloat();
@@ -117,6 +122,11 @@ private:
void recreatePersonDateTimeTable();
void recreatePersonDateTable();
void recreatePersonTimeTable();
void recreatePersonTimestampTable();
void recreatePersonLongBLOBTable();
#ifdef POCO_MYSQL_JSON
void recreatePersonJSONTable();
#endif
void recreateStringsTable();
void recreateIntsTable();
void recreateUnsignedIntsTable();
+106 -1
View File
@@ -29,7 +29,7 @@
#include <Winsock2.h>
#endif
#include <mysql/mysql.h>
#include <iostream>
#include <limits>
@@ -1364,6 +1364,34 @@ void SQLExecutor::time()
}
void SQLExecutor::timestamp()
{
std::string funct = "timestamp()";
std::string lastName("Bart");
std::string firstName("Simpson");
std::string address("Springfield");
DateTime birthday(1980, 4, 1, 5, 45, 12, 354, 879);
int count = 0;
try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(birthday), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assertTrue (count == 1);
DateTime bd;
assertTrue (bd != birthday);
try { *_pSession << "SELECT Birthday FROM Person", into(bd), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assertTrue (bd == birthday);
std::cout << std::endl << RecordSet(*_pSession, "SELECT * FROM Person");
}
void SQLExecutor::blob(unsigned int bigSize)
{
std::string funct = "blob()";
@@ -1435,6 +1463,83 @@ void SQLExecutor::blobStmt()
}
void SQLExecutor::longBlob()
{
std::string funct = "longBlob()";
std::string lastName("lastname");
std::string firstName("firstname");
std::string address("Address");
Poco::Data::CLOB biography("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", 123);
int count = 0;
Statement ins = (*_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(biography));
ins.execute();
try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assertTrue (count == 1);
Poco::Data::CLOB res;
poco_assert (res.size() == 0);
Statement stmt = (*_pSession << "SELECT Biography FROM Person", into(res));
try { stmt.execute(); }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
poco_assert (res == biography);
}
void SQLExecutor::longText()
{
std::string funct = "longText()";
std::string lastName("lastname");
std::string firstName("firstname");
std::string address("Address");
std::string biography("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", 123);
int count = 0;
Statement ins = (*_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(biography));
ins.execute();
try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assertTrue (count == 1);
std::string longTextRes;
poco_assert (longTextRes.size() == 0);
Statement stmt = (*_pSession << "SELECT Biography FROM Person", into(longTextRes));
try { stmt.execute(); }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
poco_assert (longTextRes == biography);
}
#ifdef POCO_MYSQL_JSON
void SQLExecutor::json()
{
std::string funct = "json()";
std::string lastName("lastname");
std::string firstName("firstname");
std::string address("Address");
std::string biography(R"({"biography": {"count": 42, "title": "Lorem Ipsum", "released": true}})");
int count = 0;
Statement ins = (*_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(biography));
ins.execute();
try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; }
catch (ConnectionException& ce) { std::cout << ce.displayText() << std::endl; fail(funct); }
catch (StatementException& se) { std::cout << se.displayText() << std::endl; fail(funct); }
assertTrue(count == 1);
Poco::Data::JSON res;
poco_assert(res.size() == 0);
Statement stmt = (*_pSession << "SELECT Biography FROM Person", into(res));
try { stmt.execute(); }
catch (ConnectionException& ce) { std::cout << ce.displayText() << std::endl; fail(funct); }
catch (StatementException& se) { std::cout << se.displayText() << std::endl; fail(funct); }
poco_assert(res == biography);
}
#endif
void SQLExecutor::tuples()
{
typedef Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int> TupleType;
+6
View File
@@ -83,6 +83,12 @@ public:
void dateTime();
void date();
void time();
void timestamp();
void longBlob();
void longText();
#ifdef POCO_MYSQL_JSON
void json();
#endif
void unsignedInts();
void floats();
void doubles();