32 lines
1.0 KiB
C++
32 lines
1.0 KiB
C++
#include "Database.h"
|
|
#include "BoostLog.h"
|
|
#include <boost/test/unit_test.hpp>
|
|
#include <filesystem>
|
|
|
|
static constexpr auto path = "build/database.sqlite";
|
|
using namespace std::chrono;
|
|
|
|
BOOST_AUTO_TEST_CASE(DatabaseTest) {
|
|
if (std::filesystem::exists(path)) {
|
|
std::filesystem::remove(path);
|
|
}
|
|
Database database;
|
|
BOOST_TEST(database.open(path));
|
|
|
|
database.addTask(1234, "Hello");
|
|
|
|
database.addTask(1234, "这是一个测试", "", true);
|
|
|
|
database.addHomeBoxItem("手机", "抽屉", 1499);
|
|
auto items = database.homeBoxItems();
|
|
BOOST_CHECK_EQUAL(items.size(), 1);
|
|
|
|
auto now = std::chrono::system_clock::now();
|
|
std::time_t now_time = std::chrono::system_clock::to_time_t(now);
|
|
database.setTaskFinished(1, true, now_time);
|
|
|
|
database.updateVisitCount("/note", "uuid_123", "chrome", now_time);
|
|
database.updateVisitCount("/note/1", "uuid_1232", "chrome", now_time);
|
|
database.updateVisitCount("/note", "uuid_123", "chrome", now_time);
|
|
database.updateVisitCount("/note", "uuid_1234", "chrome", now_time);
|
|
} |