big refactoring part 1
This commit is contained in:
parent
6a8f67ac34
commit
19229f6c26
28 changed files with 867 additions and 795 deletions
|
@ -1,7 +1,7 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "database.h"
|
||||
#include "table.h"
|
||||
#include "storage.h"
|
||||
#include "cache.h"
|
||||
|
||||
#include <QString>
|
||||
|
@ -18,7 +18,7 @@ protected:
|
|||
|
||||
static void SetUpTestSuite() {
|
||||
if (db == nullptr) {
|
||||
db = new DataBase("testBase");
|
||||
db = new LMDBDataBase::DataBase("testBase");
|
||||
db->addTable<uint32_t, uint32_t>("table1");
|
||||
db->addTable<QString, QString>("table2");
|
||||
db->addCache<int8_t, std::string>("cache1");
|
||||
|
@ -32,15 +32,15 @@ protected:
|
|||
db = nullptr;
|
||||
}
|
||||
|
||||
static DataBase* db;
|
||||
static LMDBDataBase::DataBase* db;
|
||||
|
||||
DataBase::Table<uint32_t, uint32_t>* t1;
|
||||
DataBase::Table<QString, QString>* t2;
|
||||
DataBase::Cache<int8_t, std::string>* c1;
|
||||
LMDBDataBase::Storage<uint32_t, uint32_t>* t1;
|
||||
LMDBDataBase::Storage<QString, QString>* t2;
|
||||
LMDBDataBase::Cache<int8_t, std::string>* c1;
|
||||
};
|
||||
|
||||
|
||||
DataBase* DataBaseTest::db = nullptr;
|
||||
LMDBDataBase::DataBase* DataBaseTest::db = nullptr;
|
||||
|
||||
TEST_F(DataBaseTest, RemovingDirectory) {
|
||||
EXPECT_EQ(db->removeDirectory(), true);
|
||||
|
@ -88,7 +88,7 @@ TEST_F(DataBaseTest, AddingRepeatingIntegerKey) {
|
|||
bool thrown = false;
|
||||
try {
|
||||
t1->addRecord(3, 24);
|
||||
} catch (const DataBase::Exist e) {
|
||||
} catch (const LMDBDataBase::Exist e) {
|
||||
thrown = true;
|
||||
}
|
||||
ASSERT_EQ(thrown, true) << "The expected behaviour is to throw exception on duplicate, but it didn't happened";
|
||||
|
@ -100,7 +100,7 @@ TEST_F(DataBaseTest, AddingRepeatingStringKey) {
|
|||
bool thrown = false;
|
||||
try {
|
||||
t2->addRecord("sdfhga", "world");
|
||||
} catch (const DataBase::Exist e) {
|
||||
} catch (const LMDBDataBase::Exist e) {
|
||||
thrown = true;
|
||||
}
|
||||
ASSERT_EQ(thrown, true) << "The expected behaviour is to throw exception on duplicate, but it didn't happened";
|
||||
|
@ -112,7 +112,7 @@ TEST_F(DataBaseTest, AddingRepeatingCacheKey) {
|
|||
bool thrown = false;
|
||||
try {
|
||||
c1->addRecord(-4, "world");
|
||||
} catch (const DataBase::Exist e) {
|
||||
} catch (const LMDBDataBase::Exist e) {
|
||||
thrown = true;
|
||||
}
|
||||
ASSERT_EQ(thrown, true) << "The expected behaviour is to throw exception on duplicate, but it didn't happened";
|
||||
|
@ -124,7 +124,7 @@ TEST_F(DataBaseTest, GettingNotExistingKeys) {
|
|||
bool thrown = false;
|
||||
try {
|
||||
QString wrong = t2->getRecord("almonds");
|
||||
} catch (const DataBase::NotFound e) {
|
||||
} catch (const LMDBDataBase::NotFound e) {
|
||||
thrown = true;
|
||||
}
|
||||
ASSERT_EQ(thrown, true) << "The expected behaviour is to throw exception on duplicate, but it didn't happened";
|
||||
|
@ -132,7 +132,7 @@ TEST_F(DataBaseTest, GettingNotExistingKeys) {
|
|||
thrown = false;
|
||||
try {
|
||||
uint32_t wrong = t1->getRecord(64);
|
||||
} catch (const DataBase::NotFound e) {
|
||||
} catch (const LMDBDataBase::NotFound e) {
|
||||
thrown = true;
|
||||
}
|
||||
ASSERT_EQ(thrown, true) << "The expected behaviour is to throw exception on duplicate, but it didn't happened";
|
||||
|
@ -140,7 +140,7 @@ TEST_F(DataBaseTest, GettingNotExistingKeys) {
|
|||
thrown = false;
|
||||
try {
|
||||
std::string wrong = c1->getRecord(21);
|
||||
} catch (const DataBase::NotFound e) {
|
||||
} catch (const LMDBDataBase::NotFound e) {
|
||||
thrown = true;
|
||||
}
|
||||
ASSERT_EQ(thrown, true) << "The expected behaviour is to throw exception on duplicate, but it didn't happened";
|
||||
|
@ -151,7 +151,7 @@ TEST_F(DataBaseTest, Persistence) {
|
|||
db->close();
|
||||
delete db;
|
||||
|
||||
db = new DataBase("testBase");
|
||||
db = new LMDBDataBase::DataBase("testBase");
|
||||
t1 = db->addTable<uint32_t, uint32_t>("table1");
|
||||
t2 = db->addTable<QString, QString>("table2");
|
||||
c1 = db->addCache<int8_t, std::string>("cache1");
|
||||
|
@ -175,7 +175,7 @@ TEST_F(DataBaseTest, Persistence) {
|
|||
bool thrown = false;
|
||||
try {
|
||||
QString wrong = t2->getRecord("cats");
|
||||
} catch (const DataBase::NotFound e) {
|
||||
} catch (const LMDBDataBase::NotFound e) {
|
||||
thrown = true;
|
||||
}
|
||||
ASSERT_EQ(thrown, true) << "The expected behaviour is to throw exception on duplicate, but it didn't happened";
|
||||
|
@ -183,7 +183,7 @@ TEST_F(DataBaseTest, Persistence) {
|
|||
thrown = false;
|
||||
try {
|
||||
uint32_t wrong = t1->getRecord(7893);
|
||||
} catch (const DataBase::NotFound e) {
|
||||
} catch (const LMDBDataBase::NotFound e) {
|
||||
thrown = true;
|
||||
}
|
||||
ASSERT_EQ(thrown, true) << "The expected behaviour is to throw exception on duplicate, but it didn't happened";
|
||||
|
@ -191,7 +191,7 @@ TEST_F(DataBaseTest, Persistence) {
|
|||
thrown = false;
|
||||
try {
|
||||
std::string wrong = c1->getRecord(89);
|
||||
} catch (const DataBase::NotFound e) {
|
||||
} catch (const LMDBDataBase::NotFound e) {
|
||||
thrown = true;
|
||||
}
|
||||
ASSERT_EQ(thrown, true) << "The expected behaviour is to throw exception on duplicate, but it didn't happened";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue