diff options
-rw-r--r-- | tests/testplan.cpp | 192 | ||||
-rw-r--r-- | tests/testplan.h | 4 |
2 files changed, 196 insertions, 0 deletions
diff --git a/tests/testplan.cpp b/tests/testplan.cpp index e8b89ba59..f09773524 100644 --- a/tests/testplan.cpp +++ b/tests/testplan.cpp @@ -58,6 +58,90 @@ void setupPlan(struct diveplan *dp) plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, oxygen, 0, 1); } +void setupPlanVpmb60m30minAir(struct diveplan *dp) +{ + dp->salinity = 10300; + dp->surface_pressure = 1013; + dp->bottomsac = 0; + dp->decosac = 0; + + struct gasmix bottomgas = { {210}, {0} }; + pressure_t po2 = { 1600 }; + displayed_dive.cylinder[0].gasmix = bottomgas; + displayed_dive.surface_pressure.mbar = 1013; + reset_cylinders(&displayed_dive, true); + free_dps(dp); + + int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330); + plan_add_segment(dp, droptime, M_OR_FT(60, 200), bottomgas, 0, 1); + plan_add_segment(dp, 30*60 - droptime, M_OR_FT(60, 200), bottomgas, 0, 1); +} + +void setupPlanVpmb60m30minEan50(struct diveplan *dp) +{ + dp->salinity = 10300; + dp->surface_pressure = 1013; + dp->bottomsac = 0; + dp->decosac = 0; + + struct gasmix bottomgas = { {210}, {0} }; + struct gasmix ean50 = { {500}, {0} }; + pressure_t po2 = { 1600 }; + displayed_dive.cylinder[0].gasmix = bottomgas; + displayed_dive.cylinder[1].gasmix = ean50; + displayed_dive.surface_pressure.mbar = 1013; + reset_cylinders(&displayed_dive, true); + free_dps(dp); + + int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330); + plan_add_segment(dp, droptime, M_OR_FT(60, 200), bottomgas, 0, 1); + plan_add_segment(dp, 30*60 - droptime, M_OR_FT(60, 200), bottomgas, 0, 1); + plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, ean50, 0, 1); +} + +void setupPlanVpmb60m30minTx(struct diveplan *dp) +{ + dp->salinity = 10300; + dp->surface_pressure = 1013; + dp->bottomsac = 0; + dp->decosac = 0; + + struct gasmix bottomgas = { {180}, {450} }; + struct gasmix ean50 = { {500}, {0} }; + pressure_t po2 = { 1600 }; + displayed_dive.cylinder[0].gasmix = bottomgas; + displayed_dive.cylinder[1].gasmix = ean50; + displayed_dive.surface_pressure.mbar = 1013; + reset_cylinders(&displayed_dive, true); + free_dps(dp); + + int droptime = M_OR_FT(60, 200) * 60 / M_OR_FT(99, 330); + plan_add_segment(dp, droptime, M_OR_FT(60, 200), bottomgas, 0, 1); + plan_add_segment(dp, 30*60 - droptime, M_OR_FT(60, 200), bottomgas, 0, 1); + plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, ean50, 0, 1); +} + +void setupPlanVpmbMultiLevelAir(struct diveplan *dp) +{ + dp->salinity = 10300; + dp->surface_pressure = 1013; + dp->bottomsac = 0; + dp->decosac = 0; + + struct gasmix bottomgas = { {210}, {0} }; + pressure_t po2 = { 1600 }; + displayed_dive.cylinder[0].gasmix = bottomgas; + displayed_dive.surface_pressure.mbar = 1013; + reset_cylinders(&displayed_dive, true); + free_dps(dp); + + int droptime = M_OR_FT(20, 66) * 60 / M_OR_FT(99, 330); + plan_add_segment(dp, droptime, M_OR_FT(20, 66), bottomgas, 0, 1); + plan_add_segment(dp, 10*60 - droptime, M_OR_FT(20, 66), bottomgas, 0, 1); + plan_add_segment(dp, 1*60, M_OR_FT(60, 200), bottomgas, 0, 1); + plan_add_segment(dp, 29*60, M_OR_FT(60, 200), bottomgas, 0, 1); +} + void setupPlanVpmb100m60min(struct diveplan *dp) { dp->salinity = 10300; @@ -180,6 +264,90 @@ void TestPlan::testImperial() QCOMPARE(displayed_dive.dc.duration.seconds, 110u * 60u - 2u); } +void TestPlan::testVpmbMetric60m30minAir() +{ + char *cache = NULL; + + setupPrefsVpmb(); + prefs.unit_system = METRIC; + prefs.units.length = units::METERS; + + struct diveplan testPlan = { 0 }; + setupPlanVpmb60m30minAir(&testPlan); + setCurrentAppState("PlanDive"); + + plan(&testPlan, &cache, 1, 0); + +#if DEBUG + free(displayed_dive.notes); + displayed_dive.notes = NULL; + save_dive(stdout, &displayed_dive); +#endif + + // check expected run time of 141 minutes + QCOMPARE(displayed_dive.dc.duration.seconds, 8480u); +} + +void TestPlan::testVpmbMetric60m30minEan50() +{ + char *cache = NULL; + + setupPrefsVpmb(); + prefs.unit_system = METRIC; + prefs.units.length = units::METERS; + + struct diveplan testPlan = { 0 }; + setupPlanVpmb60m30minEan50(&testPlan); + setCurrentAppState("PlanDive"); + + plan(&testPlan, &cache, 1, 0); + +#if DEBUG + free(displayed_dive.notes); + displayed_dive.notes = NULL; + save_dive(stdout, &displayed_dive); +#endif + + // check first gas change to EAN50 at 21m + struct event *ev = displayed_dive.dc.events; + QVERIFY(ev != NULL); + QCOMPARE(ev->gas.index, 1); + QCOMPARE(ev->value, 50); + QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 21000); + // check expected run time of 95 minutes + QCOMPARE(displayed_dive.dc.duration.seconds, 5720u); +} + +void TestPlan::testVpmbMetric60m30minTx() +{ + char *cache = NULL; + + setupPrefsVpmb(); + prefs.unit_system = METRIC; + prefs.units.length = units::METERS; + + struct diveplan testPlan = { 0 }; + setupPlanVpmb60m30minTx(&testPlan); + setCurrentAppState("PlanDive"); + + plan(&testPlan, &cache, 1, 0); + +#if DEBUG + free(displayed_dive.notes); + displayed_dive.notes = NULL; + save_dive(stdout, &displayed_dive); +#endif + + // check first gas change to EAN50 at 21m + struct event *ev = displayed_dive.dc.events; + QVERIFY(ev != NULL); + QCOMPARE(ev->gas.index, 1); + QCOMPARE(ev->value, 50); + QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 21000); + // check expected run time of 89 minutes + QCOMPARE(displayed_dive.dc.duration.seconds, 5360u); +} + void TestPlan::testVpmbMetric100m60min() { char *cache = NULL; @@ -216,6 +384,30 @@ void TestPlan::testVpmbMetric100m60min() QCOMPARE(displayed_dive.dc.duration.seconds, 18980u); } +void TestPlan::testVpmbMetricMultiLevelAir() +{ + char *cache = NULL; + + setupPrefsVpmb(); + prefs.unit_system = METRIC; + prefs.units.length = units::METERS; + + struct diveplan testPlan = { 0 }; + setupPlanVpmbMultiLevelAir(&testPlan); + setCurrentAppState("PlanDive"); + + plan(&testPlan, &cache, 1, 0); + +#if DEBUG + free(displayed_dive.notes); + displayed_dive.notes = NULL; + save_dive(stdout, &displayed_dive); +#endif + + // check expected run time of 167 minutes + QCOMPARE(displayed_dive.dc.duration.seconds, 10040u); +} + void TestPlan::testVpmbMetric100m10min() { char *cache = NULL; diff --git a/tests/testplan.h b/tests/testplan.h index 43cc6a99b..f73ad0d9a 100644 --- a/tests/testplan.h +++ b/tests/testplan.h @@ -8,6 +8,10 @@ class TestPlan : public QObject { private slots: void testImperial(); void testMetric(); + void testVpmbMetric60m30minAir(); + void testVpmbMetric60m30minEan50(); + void testVpmbMetric60m30minTx(); + void testVpmbMetricMultiLevelAir(); void testVpmbMetric100m60min(); void testVpmbMetric100m10min(); }; |