kima2/test/test_database.cpp

25 lines
621 B
C++
Raw Normal View History

2018-07-09 21:42:38 +02:00
#define BOOST_TEST_MODULE database
#include "../src/core/database.h"
2018-07-10 14:12:37 +02:00
#include <filesystem>
2018-07-09 21:42:38 +02:00
#include <boost/test/included/unit_test.hpp>
2018-07-10 15:46:55 +02:00
BOOST_AUTO_TEST_CASE(create_database)
{
std::filesystem::path testPath = std::filesystem::temp_directory_path() / "kima2test.db";
if (std::filesystem::exists(testPath)) {
std::filesystem::remove(testPath);
}
2018-07-09 21:42:38 +02:00
2018-07-10 15:46:55 +02:00
std::string filename = testPath.generic_string();
Database db(filename);
2018-07-10 14:12:37 +02:00
db.init();
2018-07-10 15:46:55 +02:00
BOOST_TEST(std::filesystem::exists(testPath) == true);
if (std::filesystem::exists(testPath)) {
std::filesystem::remove(testPath);
}
2018-07-09 21:42:38 +02:00
}