mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
Add a test for the VPM-B mode of the planner
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
41349c29dd
commit
fbce8a0378
2 changed files with 76 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
|||
#include "testplan.h"
|
||||
#include "planner.h"
|
||||
#include "units.h"
|
||||
#include "qthelper.h"
|
||||
#include <QDebug>
|
||||
|
||||
#define DEBUG 1
|
||||
|
@ -19,6 +20,18 @@ void setupPrefs()
|
|||
prefs.last_stop = true;
|
||||
}
|
||||
|
||||
void setupPrefsVpmb()
|
||||
{
|
||||
prefs = default_prefs;
|
||||
prefs.ascrate50 = 10000 / 60;
|
||||
prefs.ascrate75 = prefs.ascrate50;
|
||||
prefs.ascratestops = prefs.ascrate50;
|
||||
prefs.ascratelast6m = prefs.ascrate50;
|
||||
prefs.descrate = 99000 / 60;
|
||||
prefs.last_stop = false;
|
||||
prefs.deco_mode = VPMB;
|
||||
}
|
||||
|
||||
void setupPlan(struct diveplan *dp)
|
||||
{
|
||||
dp->salinity = 10300;
|
||||
|
@ -45,6 +58,31 @@ 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 setupPlanVpmb(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} };
|
||||
struct gasmix oxygen = { {1000}, {0} };
|
||||
pressure_t po2 = { 1600 };
|
||||
displayed_dive.cylinder[0].gasmix = bottomgas;
|
||||
displayed_dive.cylinder[1].gasmix = ean50;
|
||||
displayed_dive.cylinder[2].gasmix = oxygen;
|
||||
displayed_dive.surface_pressure.mbar = 1013;
|
||||
reset_cylinders(&displayed_dive, true);
|
||||
free_dps(dp);
|
||||
|
||||
int droptime = M_OR_FT(100, 330) * 60 / M_OR_FT(99, 330);
|
||||
plan_add_segment(dp, droptime, M_OR_FT(100, 330), bottomgas, 0, 1);
|
||||
plan_add_segment(dp, 60*60 - droptime, M_OR_FT(100, 330), bottomgas, 0, 1);
|
||||
plan_add_segment(dp, 0, gas_mod(&ean50, po2, &displayed_dive, M_OR_FT(3,10)).mm, ean50, 0, 1);
|
||||
plan_add_segment(dp, 0, gas_mod(&oxygen, po2, &displayed_dive, M_OR_FT(3,10)).mm, oxygen, 0, 1);
|
||||
}
|
||||
|
||||
void TestPlan::testMetric()
|
||||
{
|
||||
char *cache = NULL;
|
||||
|
@ -117,4 +155,41 @@ void TestPlan::testImperial()
|
|||
QCOMPARE(displayed_dive.dc.duration.seconds, 110u * 60u - 2u);
|
||||
}
|
||||
|
||||
void TestPlan::testVpmbMetric()
|
||||
{
|
||||
char *cache = NULL;
|
||||
|
||||
setupPrefsVpmb();
|
||||
prefs.unit_system = METRIC;
|
||||
prefs.units.length = units::METERS;
|
||||
|
||||
struct diveplan testPlan = { 0 };
|
||||
setupPlanVpmb(&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 second gas change to Oxygen at 6m
|
||||
ev = ev->next;
|
||||
QVERIFY(ev != NULL);
|
||||
QCOMPARE(ev->gas.index, 2);
|
||||
QCOMPARE(ev->value, 100);
|
||||
QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 6000);
|
||||
// check expected run time of 105 minutes
|
||||
QCOMPARE(displayed_dive.dc.duration.seconds, 18980u);
|
||||
}
|
||||
|
||||
|
||||
QTEST_MAIN(TestPlan)
|
||||
|
|
|
@ -8,6 +8,7 @@ class TestPlan : public QObject {
|
|||
private slots:
|
||||
void testImperial();
|
||||
void testMetric();
|
||||
void testVpmbMetric();
|
||||
};
|
||||
|
||||
#endif // TESTPLAN_H
|
||||
|
|
Loading…
Add table
Reference in a new issue