fixed memory leak

This commit is contained in:
2025-03-13 23:18:38 +01:00
parent 86b255a140
commit 6c3dc79f37
19 changed files with 284 additions and 66 deletions

View File

@ -25,13 +25,13 @@ public:
auto neededGen = std::vector<float>();
for (int i = 0; i < 5; i++) {
// Populate with test values
communityCoverage.push_back(i * 10.0f);
ownUsage.push_back(i * 5.0f);
neededCon.push_back(i * 3.0f);
neededGen.push_back(i * 2.0f);
communityCoverage.push_back(static_cast<float>(i) * 10.0f);
ownUsage.push_back(static_cast<float>(i) * 5.0f);
neededCon.push_back(static_cast<float>(i) * 3.0f);
neededGen.push_back(static_cast<float>(i) * 2.0f);
}
values->set_community_coverage(std::move(communityCoverage));
values->set_own_usage(std::move(ownUsage));
values->set_needed_con(std::move(neededCon));
@ -58,8 +58,8 @@ public:
for (int i = 0; i < 5; i++) {
// Populate with test values
consumptionProfile.push_back(i * 100.0f);
generationProfile.push_back(i * 50.0f);
consumptionProfile.push_back(static_cast<float>(i) * 100.0f);
generationProfile.push_back(static_cast<float>(i) * 50.0f);
}
metadata->set_consumption_profile(std::move(consumptionProfile));

View File

@ -2,11 +2,19 @@
// Created by StanislausCichocki on 10.03.2025.
//
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <spdlog/spdlog.h>
#include "../../src/services/Surplus.h"
#include "../../src/services/Cost/BillCharge.h"
#include "../../src/services/Cost/CalculateFinalSums.h"
#include "../../src/services/Cost/CostPipeline.h"
#include "../../src/services/Cost/NetworkProvider.h"
#include "../../src/services/Cost/ServiceCharge.h"
#include "../../src/services/Cost/GridCost/MeasurementServiceFee.h"
#include "../../src/services/Cost/GridCost/NetUsagePerformance.h"
#include "doctest/doctest.h"
#include "../model/Factory.h"
#include "../../src/Config.h"
TEST_CASE("Testing add function") {
std::vector<std::unique_ptr<Community> > communities;
@ -17,5 +25,13 @@ TEST_CASE("Testing add function") {
surplus.CalculateSurplus();
CostPipeline costPipeline(communities);
costPipeline.addCostComponent(std::make_shared<NetworkProvider>());
costPipeline.addCostComponent(std::make_shared<BillCharge>());
costPipeline.addCostComponent(std::make_shared<MeasurementServiceFee>());
costPipeline.addCostComponent(std::make_shared<NetUsagePerformance>());
costPipeline.addCostComponent(std::make_shared<ServiceCharge>());
costPipeline.addCostComponent(std::make_shared<CalculateFinalSums>());
costPipeline.calculateFinalCost();
LOG_DEBUG_INFO("{}",communities[0]->total);
CHECK(true);
}