Mercurial > dedupe
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TestDatabase.cpp Sat Feb 16 15:32:20 2013 +0100 @@ -0,0 +1,28 @@ +#include "TestDataBase.hpp" + +#include "Exception/IOException.hpp" + +TestDatabase::TestDatabase() : connectionName("TestDatabase"), + db(new QSqlDatabase) +{ + *db = QSqlDatabase::addDatabase("QSQLITE", connectionName); + const QString dbPath(":memory:"); + db->setDatabaseName(dbPath); + if (!db->open()) + throw + IOException(QString("Unable to open SQLite database with path '%1'") + .arg(dbPath)); + +} + +TestDatabase::~TestDatabase() +{ + db->close(); + delete db; + QSqlDatabase::removeDatabase(connectionName); +} + +QSqlDatabase TestDatabase::getDatabase() +{ + return *db; +}
