26 lines
904 B
C++
26 lines
904 B
C++
//
|
|
// 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
|
|
}
|
|
));
|
|
}
|
|
}
|