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