Mercurial > dedupe
comparison TestDatabase.cpp @ 76:8136057988bc
Fixes to automatic report generating system.
A lot of new unittests.
| author | Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no> |
|---|---|
| date | Sat, 16 Feb 2013 15:32:20 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 75:aaf0a2878f67 | 76:8136057988bc |
|---|---|
| 1 #include "TestDataBase.hpp" | |
| 2 | |
| 3 #include "Exception/IOException.hpp" | |
| 4 | |
| 5 TestDatabase::TestDatabase() : connectionName("TestDatabase"), | |
| 6 db(new QSqlDatabase) | |
| 7 { | |
| 8 *db = QSqlDatabase::addDatabase("QSQLITE", connectionName); | |
| 9 const QString dbPath(":memory:"); | |
| 10 db->setDatabaseName(dbPath); | |
| 11 if (!db->open()) | |
| 12 throw | |
| 13 IOException(QString("Unable to open SQLite database with path '%1'") | |
| 14 .arg(dbPath)); | |
| 15 | |
| 16 } | |
| 17 | |
| 18 TestDatabase::~TestDatabase() | |
| 19 { | |
| 20 db->close(); | |
| 21 delete db; | |
| 22 QSqlDatabase::removeDatabase(connectionName); | |
| 23 } | |
| 24 | |
| 25 QSqlDatabase TestDatabase::getDatabase() | |
| 26 { | |
| 27 return *db; | |
| 28 } |
