read bin file

This commit is contained in:
2025-03-14 16:25:25 +01:00
parent 90a16ddcb9
commit 5814fdd0cb
5 changed files with 253 additions and 1 deletions

View File

@ -0,0 +1,25 @@
//
// Created by stani on 3/14/25.
//
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <numeric>
#include <doctest/doctest.h>
#include <spdlog/spdlog.h>
#include "../../src/Config.h"
#include "../../src/helper/CsvBinary.h"
TEST_CASE("Test Csv to binary and back") {
CsvBinary::csvToBinary("Verbrauchsprofile.csv","Verbrauchsprofil.bin");
CsvBinary::binaryToCsv("Verbrauchsprofil.bin","Restored.csv");
auto verbrauchsProfil = CsvBinary::binaryToVector("Verbrauchsprofil.bin");
for (auto &row: *verbrauchsProfil) {
LOG_DEBUG_INFO("Sum from {}: {}",row.first ,std::accumulate(
row.second.begin(), row.second.end(), 0.f,
[](float sum, const std::string& val) {
return sum + std::stof(val); // Convert string to float before addition
}
));
}
}

View File

@ -1,7 +1,6 @@
//
// Created by StanislausCichocki on 10.03.2025.
//
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <spdlog/spdlog.h>
#include "../../src/services/Surplus.h"