增加了数据库及测试程序

This commit is contained in:
zjk
2025-02-10 16:37:22 +08:00
parent e072f2b9d4
commit 59faa14afb
12 changed files with 326 additions and 82 deletions
+24
View File
@@ -0,0 +1,24 @@
#include "catch2/catch.hpp"
#include "../src/pPowerManger/SQLiteDB.h"
TEST_CASE("SQLiteDB Test", "[SQLiteDB]") {
SQLiteDB db("test.db");
SECTION("Create Tables") {
db.createTables();
}
SECTION("Insert Data") {
PowerData data = {0, "2025-02-10 14:09:00", 12.5, 2.5, 31.25, 25.0};
db.insertStructData("power_data", data);
}
SECTION("Query Data") {
std::vector<PowerData> results = db.getPowerData();
REQUIRE(results.size() == 1);
REQUIRE(results[0].voltage == 12.5);
REQUIRE(results[0].current == 2.5);
REQUIRE(results[0].power == 31.25);
REQUIRE(results[0].temperature == 25.0);
}
}