void TestPlan::testImperial() { struct deco_state *cache = NULL; setupPrefs(); prefs.unit_system = IMPERIAL; prefs.units.length = units::FEET; prefs.planner_deco_mode = BUEHLMANN; struct diveplan testPlan = {}; setupPlan(&testPlan); 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 // check minimum gas result struct divedatapoint *dp = testPlan.dp; while (!dp->minimum_gas.mbar && dp->next) dp = dp->next; QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 154l); // check first gas change to EAN36 at 33m struct event *ev = displayed_dive.dc.events; QVERIFY(ev != NULL); QCOMPARE(ev->gas.index, 1); QCOMPARE(ev->value, 36); QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 33528); // 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), 6096); // check expected run time of 111 minutes QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 111u * 60u - 2u, 111u * 60u - 2u)); }
void TestPlan::testVpmbMetric100m10min() { char *cache = NULL; setupPrefsVpmb(); prefs.unit_system = METRIC; prefs.units.length = units::METERS; struct diveplan testPlan = { 0 }; setupPlanVpmb100m10min(&testPlan); setCurrentAppState("PlanDive"); plan(&testPlan, &cache, 1, 0); #if DEBUG free(displayed_dive.notes); displayed_dive.notes = NULL; save_dive(stdout, &displayed_dive); #endif // print first ceiling printf("First ceiling %.1f m\n", (mbar_to_depth(first_ceiling_pressure.mbar, &displayed_dive) * 0.001)); // 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 benchmark run time of 58 minutes, and known Subsurface runtime of 57 minutes QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 58u * 60u + 20u, 57u * 60u + 20u)); }
void TestPlan::testVpmbMetric60m30minTx() { struct deco_state *cache = NULL; setupPrefsVpmb(); prefs.unit_system = METRIC; prefs.units.length = units::METERS; struct diveplan testPlan = {}; setupPlanVpmb60m30minTx(&testPlan); setAppState(ApplicationState::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 // check minimum gas result struct divedatapoint *dp = testPlan.dp; while (!dp->minimum_gas.mbar && dp->next) dp = dp->next; QCOMPARE(lrint(dp->minimum_gas.mbar / 1000.0), 159l); // print first ceiling printf("First ceiling %.1f m\n", (mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar, &displayed_dive) * 0.001)); // 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 benchmark run time of 89 minutes, and known Subsurface runtime of 89 minutes QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 89u * 60u + 20u, 89u * 60u + 20u)); }
/* This tests that a previously calculated plan isn't affecting the calculations of the next plan. * It is NOT a 'repetitive dive' test (i.e. with a surface interval and considering tissue * saturation from the previous dive). */ void TestPlan::testVpmbMetricRepeat() { char *cache = NULL; setupPrefsVpmb(); prefs.unit_system = METRIC; prefs.units.length = units::METERS; struct diveplan testPlan = { 0 }; setupPlanVpmb30m20min(&testPlan); setCurrentAppState("PlanDive"); plan(&testPlan, &cache, 1, 0); #if DEBUG free(displayed_dive.notes); displayed_dive.notes = NULL; save_dive(stdout, &displayed_dive); #endif // print first ceiling printf("First ceiling %.1f m\n", (mbar_to_depth(first_ceiling_pressure.mbar, &displayed_dive) * 0.001)); // check benchmark run time of 27 minutes, and known Subsurface runtime of 27 minutes QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 27u * 60u + 20u, 27u * 60u + 20u)); int firstDiveRunTimeSeconds = displayed_dive.dc.duration.seconds; setupPlanVpmb100mTo70m30min(&testPlan); plan(&testPlan, &cache, 1, 0); #if DEBUG free(displayed_dive.notes); displayed_dive.notes = NULL; save_dive(stdout, &displayed_dive); #endif // print first ceiling printf("First ceiling %.1f m\n", (mbar_to_depth(first_ceiling_pressure.mbar, &displayed_dive) * 0.001)); // check first gas change to 21/35 at 66m struct event *ev = displayed_dive.dc.events; QVERIFY(ev != NULL); QCOMPARE(ev->gas.index, 1); QCOMPARE(ev->gas.mix.o2.permille, 210); QCOMPARE(ev->gas.mix.he.permille, 350); QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 66000); // check second gas change to EAN50 at 21m ev = ev->next; QCOMPARE(ev->gas.index, 2); QCOMPARE(ev->value, 50); QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 21000); // check third gas change to Oxygen at 6m ev = ev->next; QVERIFY(ev != NULL); QCOMPARE(ev->gas.index, 3); QCOMPARE(ev->value, 100); QCOMPARE(get_depth_at_time(&displayed_dive.dc, ev->time.seconds), 6000); // we don't have a benchmark, known Subsurface runtime is 126 minutes QVERIFY(compareDecoTime(displayed_dive.dc.duration.seconds, 126u * 60u + 20u, 126u * 60u + 20u)); setupPlanVpmb30m20min(&testPlan); plan(&testPlan, &cache, 1, 0); #if DEBUG free(displayed_dive.notes); displayed_dive.notes = NULL; save_dive(stdout, &displayed_dive); #endif // print first ceiling printf("First ceiling %.1f m\n", (mbar_to_depth(first_ceiling_pressure.mbar, &displayed_dive) * 0.001)); // check runtime is exactly the same as the first time int finalDiveRunTimeSeconds = displayed_dive.dc.duration.seconds; QCOMPARE(finalDiveRunTimeSeconds, firstDiveRunTimeSeconds); }