A test for gases used in the planner

This tests for the planner getting the gases in the
manually entered part of the dive wrong (as here: from
incorrect value returned by get_gasmix_at_time.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
Robert C. Helling 2018-10-30 11:55:11 +01:00 committed by bstoeger
parent d9f2b537af
commit 7e4c8c387b
2 changed files with 54 additions and 0 deletions

View file

@ -316,6 +316,32 @@ void setupPlanVpmb100mTo70m30min(struct diveplan *dp)
plan_add_segment(dp, (30 - 20 - 3) * 60, M_OR_FT(70, 230), 0, 0, 1, OC);
}
/* This tests handling different gases in the manually entered part of the dive */
void setupPlanSeveralGases(struct diveplan *dp)
{
dp->salinity = 10300;
dp->surface_pressure = 1013;
dp->bottomsac = prefs.bottomsac;
dp->decosac = prefs.decosac;
struct gasmix ean36 = {{360}, {0}};
struct gasmix tx11_50 = {{110}, {500}};
displayed_dive.cylinder[0].gasmix = ean36;
displayed_dive.cylinder[0].type.size.mliter = 36000;
displayed_dive.cylinder[0].type.workingpressure.mbar = 232000;
displayed_dive.cylinder[1].gasmix = tx11_50;
displayed_dive.surface_pressure.mbar = 1013;
reset_cylinders(&displayed_dive, true);
free_dps(dp);
plan_add_segment(dp, 120, 40000, 0, 0, true, OC);
plan_add_segment(dp, 18 * 60, 40000, 0, 0, true, OC);
plan_add_segment(dp, 10 * 60, 10000, 1, 0, true, OC);
plan_add_segment(dp, 5 * 60, 10000, 0, 0, true, OC);
}
/* We compare the calculated runtimes against two values:
* - Known runtime calculated by Subsurface previously (to detect if anything has changed)
* - Benchmark runtime (we should be close, but not always exactly the same)
@ -643,6 +669,33 @@ void TestPlan::testVpmbMetric100m60min()
QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 311u * 60u + 20u, 315u * 60u + 20u));
}
void TestPlan::testMultipleGases()
{
struct deco_state *cache = NULL;
setupPrefsVpmb();
prefs.unit_system = METRIC;
prefs.units.length = units::METERS;
struct diveplan testPlan = {};
setupPlanSeveralGases(&testPlan);
setCurrentAppState("PlanDive");
plan(&test_deco_state, &testPlan, &displayed_dive, 60, stoptable, &cache, 1, 0);
#if DEBUG
free(displayed_dive.notes);
displayed_dive.notes = NULL;
save_dive(stdout, &displayed_dive, false);
#endif
gasmix gas;
gas = get_gasmix_at_time(&displayed_dive, &displayed_dive.dc, {20 * 60 + 1});
QCOMPARE(get_o2(gas), 110);
QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 2480u, 2480u));
}
void TestPlan::testVpmbMetricMultiLevelAir()
{
struct deco_state *cache = NULL;

View file

@ -18,6 +18,7 @@ private slots:
void testVpmbMetricMultiLevelAir();
void testVpmbMetric100m10min();
void testVpmbMetricRepeat();
void testMultipleGases();
};
#endif // TESTPLAN_H