增加了数据库及测试程序
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user