25 lines
686 B
C++
25 lines
686 B
C++
#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);
|
|
}
|
|
}
|