33 lines
1020 B
C++
33 lines
1020 B
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 = duration_cast<seconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
|
database.setTaskFinished(1, true, now);
|
|
|
|
database.updateTodayVisitCount("/note", "uuid_123");
|
|
database.updateTodayVisitCount("/note/1", "uuid_1232");
|
|
database.updateTodayVisitCount("/note", "uuid_123");
|
|
database.updateTodayVisitCount("/note", "uuid_1234");
|
|
|
|
database.updateVisitCount();
|
|
} |