From 1069c5ad907236c051d25c6bf349a91582050318 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Fri, 12 May 2023 12:43:07 +0200 Subject: [PATCH] main: add test for GetDurationFromCost --- main/main.cpp | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/main/main.cpp b/main/main.cpp index c4ed0f5..ffd6e8c 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -27,11 +27,45 @@ extern "C" char* strptime(const char* s, #include #include +#include + +#include +#include +#include "calculator_functions.h" int main() { + std::ifstream input(QDir::homePath().append("/tariff01.json").toStdString()); + 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; + + char const *startDate = ""; + + if (isParsed) + { + startDate = "2023-05-10T13:52:18.665Z"; + std::string duration = calculator.GetDurationFromCost(&cfg, 3, (char *)startDate, 33, false, true); + cout << "---> startDate " << startDate << " _price_ = " << 33 + << " Total duration is: " << duration << endl; + } + + return 0; + + + + + + + parking_tariff_t *tariff = 0; - if (init_tariff(&tariff, "/etc/psa_tariff/")) { + if (init_tariff(&tariff, "/etc/psa_tariff/")) { struct price_t price; memset(&price, 0x00, sizeof(price)); QDateTime start = QDateTime::currentDateTime();