view TestDataBase.cpp @ 77:a827f3687c4a

Compile fix Linux, wrong capitalization.
author Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no>
date Sat, 16 Feb 2013 19:00:54 +0100
parents TestDatabase.cpp@8136057988bc
children
line wrap: on
line source

#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;
}