From d0e06999065dba8c3ec0d730770ff310c147cafd Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 12 Dec 2023 10:59:49 +0100 Subject: [PATCH] Add tests for linsinger maschinenbau. --- main/main.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index 35bb543..6e0bb8a 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -33,11 +33,53 @@ extern "C" char* strptime(const char* s, #include "calculator_functions.h" #include -#define SZEGED (1) -#define NEUHAUSER_KORNEUBURG (0) +#define SZEGED (0) +#define NEUHAUSER_KORNEUBURG (0) +#define NEUHAUSER_LINSINGER_MASCHINENBAU (1) int main() { +#if NEUHAUSER_LINSINGER_MASCHINENBAU==1 + std::ifstream input("/tmp/tariff_linsinger_maschinenbau.json"); + + std::stringstream sstr; + while(input >> sstr.rdbuf()); + std::string json(sstr.str()); + + Calculator calculator; + Configuration cfg; + + bool isParsed = cfg.ParseJson(&cfg, json.c_str()); + cout << endl; + + if (isParsed) { + bool nextDay = false; + bool prePaid = false; + + // zone 1 (lila) + QDateTime s(QDate(2023, 11, 30), QTime()); + QDateTime end; + int marken[] = { 3*60, 5*60, 10*60}; + for (int duration = 0; duration < 3; ++duration) { + for (int offset = 360; offset <= 1080; ++offset) { + QDateTime start = s.addSecs(offset * 60); + //qCritical() << "start" << start.toString(Qt::ISODate); + + double cost = calculator.GetCostFromDuration(&cfg, 4, start, end, marken[duration], nextDay, prePaid); + //qCritical() << ""; + //qCritical() << "start" << start.toString(Qt::ISODate) + // << "end" << end.toString(Qt::ISODate) + // << "duration" << marken[duration] + // << "cost" << cost; + + std::string d = calculator.GetDurationFromCost(&cfg, 4, start.toString(Qt::ISODate).toStdString().c_str(), cost); + qCritical() << "start" << start.toString(Qt::ISODate) + << "cost" << cost + << "until" << d.c_str() << start.secsTo(QDateTime::fromString(d.c_str(), Qt::ISODate)) / 60; + } + } + } +#endif #if NEUHAUSER_KORNEUBURG==1 std::ifstream input("/tmp/tariff_korneuburg.json");