From 8d3f2e4ca6933c404d8f50c10c34471f1ab00214 Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Wed, 18 Oct 2023 07:32:36 +0200 Subject: [PATCH] Add another test for formatDiveGasString This adds a test for the bug just fixed, where we have a trimix gas and nitrox/air with less o2 than the trimix. Signed-off-by: Anton Lundin --- tests/testformatDiveGasString.cpp | 27 +++++++++++++++++++++++++++ tests/testformatDiveGasString.h | 1 + 2 files changed, 28 insertions(+) diff --git a/tests/testformatDiveGasString.cpp b/tests/testformatDiveGasString.cpp index 063022563..a9518ee1a 100644 --- a/tests/testformatDiveGasString.cpp +++ b/tests/testformatDiveGasString.cpp @@ -208,4 +208,31 @@ void TestformatDiveGasString::test_ccr() { QCOMPARE(formatDiveGasString(&dive), "21/35"); } +void TestformatDiveGasString::test_ccr_bailout() { + struct dive dive = {0}; + cylinder_t *cylinder = get_or_create_cylinder(&dive, 0); + + cylinder->gasmix.o2.permille = 1000; + cylinder->cylinder_use = OXYGEN; + cylinder->start.mbar = 230000; + cylinder->end.mbar = 100000; + + cylinder = get_or_create_cylinder(&dive, 1); + + cylinder->gasmix.o2.permille = 220; + cylinder->gasmix.he.permille = 200; + cylinder->cylinder_use = DILUENT; + cylinder->start.mbar = 230000; + cylinder->end.mbar = 100000; + + cylinder = get_or_create_cylinder(&dive, 2); + + cylinder->gasmix.o2.permille = 210; + cylinder->gasmix.he.permille = 0; + cylinder->start.mbar = 230000; + cylinder->end.mbar = 100000; + + QCOMPARE(formatDiveGasString(&dive), "22/20"); +} + QTEST_GUILESS_MAIN(TestformatDiveGasString) diff --git a/tests/testformatDiveGasString.h b/tests/testformatDiveGasString.h index ee04110a4..2a3c799bd 100644 --- a/tests/testformatDiveGasString.h +++ b/tests/testformatDiveGasString.h @@ -18,4 +18,5 @@ private slots: void test_trimix_and_nitrox_same_o2(); void test_trimix_and_nitrox_lower_o2(); void test_ccr(); + void test_ccr_bailout(); };