From 068575f8e822c92a0f06c4d23f45f890e68c471d Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 4 Jun 2024 11:27:57 +0200 Subject: [PATCH] improved tests --- main/main.cpp | 425 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 405 insertions(+), 20 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index e0736f7..e9a9e15 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -28,22 +28,23 @@ extern "C" char* strptime(const char* s, #include #include #include +#include +#include #include #include #include "calculator_functions.h" #include "calculate_price.h" -#define SZEGED (0) +#define SZEGED (1) #define SCHOENAU_KOENIGSEE (0) #define NEUHAUSER_KORNEUBURG (0) #define NEUHAUSER_LINSINGER_MASCHINENBAU (0) #define NEUHAUSER_NORDISCHES_AUSBILDUNGSZENTRUM (0) #define NEUHAUSER_BILEXA_GALTUER (0) -#define NEUHAUSER_KIRCHDORF (0) #define BAD_NEUENAHR_AHRWEILER (0) #define NEUHAUSER_CHRISTOPH_REISEN (0) -#define NEUHAUSER_PERNEGG_AN_DER_MUR (1) +#define NEUHAUSER_PERNEGG_AN_DER_MUR (0) #if NEUHAUSER_KIRCHDORF==1 static bool test_neuhauser_kirchdorf(int step, double cost) { @@ -264,6 +265,18 @@ int main() { price = get_minimal_parkingprice(&cfg, PERMIT_TYPE::DAY_TICKET); qCritical() << QString("line=%1 get_minimal_parkingprice:").arg(__LINE__) << price; + + for (int h = 0; h < 24; ++h) { + start.setTime(QTime(h, 0, 0)); + productStart = productEnd = QDateTime(); + price = compute_product_price(&cfg, PERMIT_TYPE::DAY_TICKET, start, &productStart, &productEnd); + qCritical() << QString("line=%1 %2 price (%3-%4) :") + .arg(__LINE__) + .arg(start.time().toString(Qt::ISODate)) + .arg(productStart.time().toString(Qt::ISODate)) + .arg(productEnd.time().toString(Qt::ISODate)) + << price; + } } #endif @@ -344,7 +357,7 @@ int main() { // 2024-05-05 10:02:30 struct price_t costs; - double const cost[] = {600, 700, 800, 1600, 2400, 3000, 3600}; + double const cost[] = {600, 700, 800, 1600, 2400, 3200, 4000}; double price1 = 0; double price2 = 0; @@ -391,7 +404,7 @@ int main() { int pop_carry_over; int pop_carry_over_time_range_id; - for (int zone=6; zone < 7; ++zone) { + for (int zone=1; zone < 2; ++zone) { //for (int t=6; t < 7; t+=20) { switch (zone) { case 1: { @@ -1044,9 +1057,179 @@ int main() { &cfg, start, timeSteps.at(i)); - qDebug() << "GetCostFromDuration() time: " << timeSteps.at(i) - << "(" << timeSteps.at(i)/60 << "h)" - << "price=" << price; + qCritical() << "zone" << zone + << "GetCostFromDuration() time: " << timeSteps.at(i) + << "(" << timeSteps.at(i)/60 << "h)" + << "price=" << price; + + switch(timeSteps.at(i)) { + case 60: + if (zone == 1) { + if (price == 300.0) { + continue; + } + } + if (zone == 2) { + if (price == 300.0) { + continue; + } + } + if (zone == 3) { + if (price == 200.0) { + continue; + } + } + break; + case 180: + if (zone == 1) { + if (price == 700.0) { + continue; + } + } + if (zone == 2) { + if (price == 500.0) { + continue; + } + } + if (zone == 3) { + if (price == 400.0) { + continue; + } + } + break; + case 1440: + if (zone == 1) { + if (price == 900.0) { + continue; + } + } + if (zone == 2) { + if (price == 600.0) { + continue; + } + } + if (zone == 3) { + if (price == 500.0) { + continue; + } + } + break; + case 2880: + if (zone == 1) { + if (price == 1800.0) { + continue; + } + } + if (zone == 2) { + if (price == 1200.0) { + continue; + } + } + break; + case 4320: + if (zone == 1) { + if (price == 2700.0) { + continue; + } + } + if (zone == 2) { + if (price == 1800.0) { + continue; + } + } + break; + case 5760: + if (zone == 1) { + if (price == 3600.0) { + continue; + } + } + if (zone == 2) { + if (price == 2400.0) { + continue; + } + } + break; + case 7200: + if (zone == 1) { + if (price == 4500.0) { + continue; + } + } + if (zone == 2) { + if (price == 3000.0) { + continue; + } + } + break; + case 8640: + if (zone == 1) { + if (price == 5400.0) { + continue; + } + } + if (zone == 2) { + if (price == 3600.0) { + continue; + } + } + break; + case 10080: + if (zone == 1) { + if (price == 6300.0) { + continue; + } + } + if (zone == 2) { + if (price == 4200.0) { + continue; + } + } + break; + case 11520: + if (zone == 1) { + if (price == 7200.0) { + continue; + } + } + if (zone == 2) { + if (price == 4800.0) { + continue; + } + } + break; + case 12960: + if (zone == 1) { + if (price == 8100.0) { + continue; + } + } + if (zone == 2) { + if (price == 5400.0) { + continue; + } + } + break; + case 14400: + if (zone == 1) { + if (price == 9000.0) { + continue; + } + } + if (zone == 2) { + if (price == 6000.0) { + continue; + } + } + break; + default: + qCritical() << "ERROR zone" << zone + << "GetCostFromDuration() time: " << timeSteps.at(i) + << "(" << timeSteps.at(i)/60 << "h)" + << "price=" << price; + exit(-1); + } + } } } @@ -1427,15 +1610,25 @@ int main() { exit(-1); } + QSet const prices{700, 1400, 2100, 2800, 3500, 4200, 4900}; + for (int i=0; i pop_max_time) { qCritical() << "ERROR pop_min_time > pop_max_time" << pop_min_time << pop_max_time; @@ -1778,7 +2161,7 @@ int main() { m.insert(115, 499); m.insert(120, 520); - m.insert(125, 524); + m.insert(125, 542); m.insert(130, 564); m.insert(135, 585); m.insert(140, 607); @@ -2197,17 +2580,19 @@ int main() { return -1; } -// start = s.addSecs(offset * 60); -// end = QDateTime(); - //if (compute_duration_for_daily_ticket(&cfg, start, end)) { -// -// } else { -// qCritical() << "ERROR computing_duration_for_daily_ticket AT" -// << "start" << start.toString(Qt::ISODate); -// return -1; -// } + // this->getDayTicketPrice(PERMIT_TYPE::DAY_TICKET) - ++cnt; + // start = s.addSecs(offset * 60); + // end = QDateTime(); + // if (compute_duration_for_daily_ticket(&cfg, start, end)) { + // + // } else { + // qCritical() << "ERROR computing_duration_for_daily_ticket AT" + // << "start" << start.toString(Qt::ISODate); + // return -1; + // } + + // ++cnt; } } }