From 7b6ace8f265e12704cc1d7e0c6f26dfe51ea2809 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Tue, 15 Nov 2011 12:04:57 +0200 Subject: Add tests for Oracle LOB support of QByteArray and QString --- qt/oracle/basic/driver.cxx | 13 ++++++++++--- qt/oracle/basic/test.hxx | 18 +++++++++++++++--- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/qt/oracle/basic/driver.cxx b/qt/oracle/basic/driver.cxx index 926ea8f..39f6b41 100644 --- a/qt/oracle/basic/driver.cxx +++ b/qt/oracle/basic/driver.cxx @@ -9,6 +9,7 @@ #include // std::auto_ptr #include #include +#include #include #include @@ -28,9 +29,15 @@ main (int argc, char* argv[]) { auto_ptr db (create_database (argc, argv)); + string long_str (20000, 'l'); + object o; - o.str = "John Doe"; - o.blob = QByteArray ("\0x13\0xDE\0x00\0x00\0x00\0x54\0xF2\0x6A", 8); + o.varchar = "John Doe"; + o.clob = QString::fromStdString (string (150, 'c')); + o.nclob = QString::fromStdString (long_str); + o.raw = QByteArray ("\0x13\0xDE\0x00\0x00\0x00\0x54\0xF2\0x6A", 8); + o.blob = QByteArray (long_str.c_str (), + static_cast (long_str.size ())); // Persist. // @@ -44,7 +51,7 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); - object* ol = db->load (o.str); + object* ol = db->load (o.varchar); t.commit (); assert (*ol == o); diff --git a/qt/oracle/basic/test.hxx b/qt/oracle/basic/test.hxx index 25710c0..979e11f 100644 --- a/qt/oracle/basic/test.hxx +++ b/qt/oracle/basic/test.hxx @@ -16,14 +16,26 @@ struct object operator== (const object& x) const { return - str == x.str && - blob == x.blob; + varchar == x.varchar && + clob == x.clob && + nclob == x.nclob && + blob == x.blob && + raw == x.raw; } #pragma db id - QString str; + QString varchar; + + #pragma db type ("CLOB") + QString clob; + + #pragma db type ("NCLOB") + QString nclob; QByteArray blob; + + #pragma db type ("RAW(128)") + QByteArray raw; }; #endif // TEST_HXX -- cgit v1.1