Files
sim/tests/helper/test_CsvBinary.cpp
2025-03-16 16:32:22 +01:00

25 lines
837 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");
auto verbrauchsProfil = CsvBinary::binaryToVector("Verbrauchsprofil.bin");
for (const auto & [fst, snd]: *verbrauchsProfil) {
LOG_DEBUG_INFO("Sum from {}: {}",fst ,std::accumulate(
snd.begin(), snd.end(), 0.f,
[](const float sum, const std::string& val) {
return sum + std::stof(val); // Convert string to float before addition
}
));
}
}