project name change

This commit is contained in:
Blue 2023-03-21 14:05:54 +03:00
parent 19229f6c26
commit 7377f13534
Signed by: blue
GPG key ID: 9B203B252A63EE38
29 changed files with 316 additions and 310 deletions

View file

@ -8,14 +8,14 @@ add_executable(runUnitTests
target_compile_options(runUnitTests PRIVATE -fPIC)
target_include_directories(runUnitTests PRIVATE ${CMAKE_SOURCE_DIR})
target_include_directories(runUnitTests PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_include_directories(runUnitTests PRIVATE ${Qt${QT_VERSION_MAJOR}_INCLUDE_DIRS})
target_include_directories(runUnitTests PRIVATE ${Qt${QT_VERSION_MAJOR}Core_INCLUDE_DIRS})
target_link_libraries(
runUnitTests
GTest::gtest_main
storage
lmdbal
)
include(GoogleTest)

View file

@ -1,24 +1,24 @@
#include <gtest/gtest.h>
#include "database.h"
#include "base.h"
#include "storage.h"
#include "cache.h"
#include <QString>
class DataBaseTest : public ::testing::Test {
class BaseTest : public ::testing::Test {
protected:
DataBaseTest():
BaseTest():
::testing::Test(),
t1(db->getTable<uint32_t, uint32_t>("table1")),
t2(db->getTable<QString, QString>("table2")),
c1(db->getCache<int8_t, std::string>("cache1")) {}
~DataBaseTest() {}
~BaseTest() {}
static void SetUpTestSuite() {
if (db == nullptr) {
db = new LMDBDataBase::DataBase("testBase");
db = new LMDBAL::Base("testBase");
db->addTable<uint32_t, uint32_t>("table1");
db->addTable<QString, QString>("table2");
db->addCache<int8_t, std::string>("cache1");
@ -32,21 +32,21 @@ protected:
db = nullptr;
}
static LMDBDataBase::DataBase* db;
static LMDBAL::Base* db;
LMDBDataBase::Storage<uint32_t, uint32_t>* t1;
LMDBDataBase::Storage<QString, QString>* t2;
LMDBDataBase::Cache<int8_t, std::string>* c1;
LMDBAL::Storage<uint32_t, uint32_t>* t1;
LMDBAL::Storage<QString, QString>* t2;
LMDBAL::Cache<int8_t, std::string>* c1;
};
LMDBDataBase::DataBase* DataBaseTest::db = nullptr;
LMDBAL::Base* BaseTest::db = nullptr;
TEST_F(DataBaseTest, RemovingDirectory) {
TEST_F(BaseTest, RemovingDirectory) {
EXPECT_EQ(db->removeDirectory(), true);
}
TEST_F(DataBaseTest, OpeningClosingDatabase) {
TEST_F(BaseTest, OpeningClosingDatabase) {
EXPECT_EQ(db->ready(), false);
db->open();
EXPECT_EQ(db->ready(), true);
@ -56,7 +56,7 @@ TEST_F(DataBaseTest, OpeningClosingDatabase) {
EXPECT_EQ(db->ready(), true);
}
TEST_F(DataBaseTest, AddingIntegerKey) {
TEST_F(BaseTest, AddingIntegerKey) {
EXPECT_EQ(db->ready(), true);
t1->addRecord(1, 2);
t1->addRecord(2, 2);
@ -64,7 +64,7 @@ TEST_F(DataBaseTest, AddingIntegerKey) {
EXPECT_EQ(t1->getRecord(1), 2);
}
TEST_F(DataBaseTest, AddingQStringKey) {
TEST_F(BaseTest, AddingQStringKey) {
EXPECT_EQ(db->ready(), true);
t2->addRecord("hello", "world");
t2->addRecord("aaa", "gagdfsdf");
@ -73,7 +73,7 @@ TEST_F(DataBaseTest, AddingQStringKey) {
EXPECT_EQ(t2->getRecord("hello"), "world");
}
TEST_F(DataBaseTest, AddingKeysToCache) {
TEST_F(BaseTest, AddingKeysToCache) {
EXPECT_EQ(db->ready(), true);
c1->addRecord(2, "blah balah");
c1->addRecord(-4, "testing goes brrr");
@ -83,48 +83,48 @@ TEST_F(DataBaseTest, AddingKeysToCache) {
EXPECT_EQ(c1->getRecord(-116), "whatever");
}
TEST_F(DataBaseTest, AddingRepeatingIntegerKey) {
TEST_F(BaseTest, AddingRepeatingIntegerKey) {
EXPECT_EQ(db->ready(), true);
bool thrown = false;
try {
t1->addRecord(3, 24);
} catch (const LMDBDataBase::Exist e) {
} catch (const LMDBAL::Exist e) {
thrown = true;
}
ASSERT_EQ(thrown, true) << "The expected behaviour is to throw exception on duplicate, but it didn't happened";
EXPECT_EQ(t1->getRecord(3), 15);
}
TEST_F(DataBaseTest, AddingRepeatingStringKey) {
TEST_F(BaseTest, AddingRepeatingStringKey) {
EXPECT_EQ(db->ready(), true);
bool thrown = false;
try {
t2->addRecord("sdfhga", "world");
} catch (const LMDBDataBase::Exist e) {
} catch (const LMDBAL::Exist e) {
thrown = true;
}
ASSERT_EQ(thrown, true) << "The expected behaviour is to throw exception on duplicate, but it didn't happened";
EXPECT_EQ(t2->getRecord("sdfhga"), "DSFFDG");
}
TEST_F(DataBaseTest, AddingRepeatingCacheKey) {
TEST_F(BaseTest, AddingRepeatingCacheKey) {
EXPECT_EQ(db->ready(), true);
bool thrown = false;
try {
c1->addRecord(-4, "world");
} catch (const LMDBDataBase::Exist e) {
} catch (const LMDBAL::Exist e) {
thrown = true;
}
ASSERT_EQ(thrown, true) << "The expected behaviour is to throw exception on duplicate, but it didn't happened";
EXPECT_EQ(c1->getRecord(-4), "testing goes brrr");
}
TEST_F(DataBaseTest, GettingNotExistingKeys) {
TEST_F(BaseTest, GettingNotExistingKeys) {
EXPECT_EQ(db->ready(), true);
bool thrown = false;
try {
QString wrong = t2->getRecord("almonds");
} catch (const LMDBDataBase::NotFound e) {
} catch (const LMDBAL::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 LMDBDataBase::NotFound e) {
} catch (const LMDBAL::NotFound e) {
thrown = true;
}
ASSERT_EQ(thrown, true) << "The expected behaviour is to throw exception on duplicate, but it didn't happened";
@ -140,18 +140,18 @@ TEST_F(DataBaseTest, GettingNotExistingKeys) {
thrown = false;
try {
std::string wrong = c1->getRecord(21);
} catch (const LMDBDataBase::NotFound e) {
} catch (const LMDBAL::NotFound e) {
thrown = true;
}
ASSERT_EQ(thrown, true) << "The expected behaviour is to throw exception on duplicate, but it didn't happened";
}
TEST_F(DataBaseTest, Persistence) {
TEST_F(BaseTest, Persistence) {
EXPECT_EQ(db->ready(), true);
db->close();
delete db;
db = new LMDBDataBase::DataBase("testBase");
db = new LMDBAL::Base("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 LMDBDataBase::NotFound e) {
} catch (const LMDBAL::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 LMDBDataBase::NotFound e) {
} catch (const LMDBAL::NotFound e) {
thrown = true;
}
ASSERT_EQ(thrown, true) << "The expected behaviour is to throw exception on duplicate, but it didn't happened";
@ -191,13 +191,13 @@ TEST_F(DataBaseTest, Persistence) {
thrown = false;
try {
std::string wrong = c1->getRecord(89);
} catch (const LMDBDataBase::NotFound e) {
} catch (const LMDBAL::NotFound e) {
thrown = true;
}
ASSERT_EQ(thrown, true) << "The expected behaviour is to throw exception on duplicate, but it didn't happened";
}
TEST_F(DataBaseTest, CountAndDrop) {
TEST_F(BaseTest, CountAndDrop) {
EXPECT_EQ(db->ready(), true);
EXPECT_EQ(t1->count(), 3);
EXPECT_EQ(t2->count(), 4);
@ -219,7 +219,7 @@ TEST_F(DataBaseTest, CountAndDrop) {
EXPECT_EQ(c1->count(), 2);
}
TEST_F(DataBaseTest, Change) {
TEST_F(BaseTest, Change) {
EXPECT_EQ(db->ready(), true);
EXPECT_EQ(t1->count(), 1);
EXPECT_EQ(t2->count(), 1);
@ -253,7 +253,7 @@ TEST_F(DataBaseTest, Change) {
EXPECT_EQ(c1->count(), 3);
}
TEST_F(DataBaseTest, Force) {
TEST_F(BaseTest, Force) {
EXPECT_EQ(db->ready(), true);
t1->forceRecord(58, 35); //changing