comparison src/Tests/deco_volume_test.cpp @ 285:cd2320cd6f9a

NEW unit tests for gas volumes...
author jdg@air
date Fri, 29 May 2015 01:25:45 +0200
parents
children 729b01914098
comparison
equal deleted inserted replaced
284:d1117b99fd99 285:cd2320cd6f9a
1 //////////////////////////////////////////////////////////////////////////////
2 /// deco_volume_test.cpp
3 /// Unit test for gas consumption c code.
4 /// Copyright (c) 2015, JD Gascuel, HeinrichsWeikamp, all right reserved.
5 //////////////////////////////////////////////////////////////////////////////
6 // HISTORY
7 // 2015-05-27 jDG: Creation for gas volum re-introduction in hwOS 1.80
8
9 extern "C" {
10 # include "p2_deco.c"
11 }
12
13 #include <gtest/gtest.h>
14
15 //////////////////////////////////////////////////////////////////////////////
16 /// \brief Defines a default OC gas list
17 static void setup_gas()
18 {
19 char_I_first_gas = 1;
20 char_I_const_ppO2 = 0; // Default to OC mode
21
22 #define DEFINE_GAS(gas, o2, he, depth, role) \
23 char_I_deco_N2_ratio [gas-1] = 100 - o2 - he; \
24 char_I_deco_He_ratio [gas-1] = he; \
25 char_I_deco_gas_change[gas-1] = depth;
26
27 DEFINE_GAS(1, 21, 0, 0, 1); // Gas#1 : Air FIRST
28 DEFINE_GAS(2, 18, 30, 0, 2); // Gas#2 : Tx18/30 TRAVEL
29 DEFINE_GAS(3, 80, 0, 9, 3); // Gas#3 : Nx80 @ 9m DECO
30 DEFINE_GAS(4, 21, 0, 10, 0); // Gas#2 : air @ 10m DISABLED
31 DEFINE_GAS(5, 21, 0, 40, 0); // Gas#2 : air @ 40m DISABLED
32 }
33
34 //////////////////////////////////////////////////////////////////////////////
35 /// \brief Define a default deco plan.
36 static void setup_plan()
37 {
38 // 1 min at 12m
39 char_O_deco_time [0] = 1;
40 char_O_deco_depth[0] =12;
41 char_O_deco_gas [0] = 1; // Gas#1
42 // 1 min at 9m
43 char_O_deco_time [1] = 1;
44 char_O_deco_depth[1] = 9;
45 char_O_deco_gas [1] = 3; // Gas#3
46 // 3min at 6m
47 char_O_deco_time [2] = 3;
48 char_O_deco_depth[2] = 6;
49 char_O_deco_gas [2] = 3; // Gas#3
50 // 12 min at 3m
51 char_O_deco_time [3] =12;
52 char_O_deco_depth[3] = 3;
53 char_O_deco_gas [3] = 3; // Gas#3
54 // Done
55 for(int s=4; s<NUM_STOPS; ++s) {
56 char_O_deco_time [s] = 0;
57 char_O_deco_depth[s] = 0;
58 char_O_deco_gas [s] = 0;
59 }
60 }
61
62 static void setup_dive(int bottom, int depth)
63 {
64 setup_gas();
65 setup_plan();
66
67 char_I_bottom_depth = bottom;
68 char_I_bottom_time = depth;
69 }
70
71 //////////////////////////////////////////////////////////////////////////////
72
73 TEST(gas_volume, run)
74 {
75 setup_dive(30, 40); // 30' @ 40m
76
77 EXPECT_NO_THROW( deco_gas_volumes() );
78 }