diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2024-01-25 20:32:06 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2024-01-25 20:32:06 +0300 |
commit | 0d49ea1fe08cf1eab41a00149393a291c65a59d7 (patch) | |
tree | 0391eb09309ca95282e200516937e64d89f3e1bb /odb-tests/qt/mssql/basic | |
parent | fc3fb39c90ab7fe5fccbe3f3bc0eb2645157bb96 (diff) |
Turn odb-tests repository into package for muti-package repositoryodb-tests
Diffstat (limited to 'odb-tests/qt/mssql/basic')
-rw-r--r-- | odb-tests/qt/mssql/basic/driver.cxx | 65 | ||||
-rw-r--r-- | odb-tests/qt/mssql/basic/test.hxx | 46 |
2 files changed, 111 insertions, 0 deletions
diff --git a/odb-tests/qt/mssql/basic/driver.cxx b/odb-tests/qt/mssql/basic/driver.cxx new file mode 100644 index 0000000..fca335d --- /dev/null +++ b/odb-tests/qt/mssql/basic/driver.cxx @@ -0,0 +1,65 @@ +// file : qt/mssql/basic/driver.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Qt basic type persistence. SQL Server version. +// + +#include <memory> // std::auto_ptr +#include <cassert> +#include <iostream> + +#include <QtCore/QCoreApplication> + +#include <odb/mssql/database.hxx> +#include <odb/mssql/transaction.hxx> + +#include <common/common.hxx> + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + QCoreApplication app (argc, argv); + + try + { + auto_ptr<database> db (create_database (argc, argv)); + + object o; + o.id_ = "object 1"; + o.sstr_ = QString (512, 's'); + o.lstr_ = QString (65000, 'l'); // Test temp buffer boundary. + o.snstr_ = QString (512, QChar (0x1234)); + o.lnstr_ = QString (65536, QChar (0x2345)); + o.sbuf_ = QByteArray (512, 0x01); + o.lbuf_ = QByteArray (65536, 0x02); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (o); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + auto_ptr<object> p (db->load<object> (o.id_)); + t.commit (); + + assert (*p == o); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/odb-tests/qt/mssql/basic/test.hxx b/odb-tests/qt/mssql/basic/test.hxx new file mode 100644 index 0000000..bce87b6 --- /dev/null +++ b/odb-tests/qt/mssql/basic/test.hxx @@ -0,0 +1,46 @@ +// file : qt/mssql/basic/test.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include <QtCore/QString> +#include <QtCore/QByteArray> + +#pragma db object +struct object +{ + bool + operator== (const object& x) const + { + return + id_ == x.id_ && + sstr_ == x.sstr_ && + lstr_ == x.lstr_ && + snstr_ == x.snstr_ && + lnstr_ == x.lnstr_ && + sbuf_ == x.sbuf_ && + lbuf_ == x.lbuf_; + } + + #pragma db id + QString id_; + + QString sstr_; + + #pragma db type ("VARCHAR(max)") + QString lstr_; + + #pragma db type ("NVARCHAR(512)") + QString snstr_; + + #pragma db type ("NVARCHAR(max)") + QString lnstr_; + + #pragma db type ("VARBINARY(512)") + QByteArray sbuf_; + + QByteArray lbuf_; +}; + +#endif // TEST_HXX |