Mercurial > public > hwos_code
comparison src/Tests/deco_volume_test.cpp @ 286:729b01914098
NEW test w/o stops and with stops
author | jdg@air |
---|---|
date | Fri, 29 May 2015 02:07:28 +0200 |
parents | cd2320cd6f9a |
children | 08986d479b94 |
comparison
equal
deleted
inserted
replaced
285:cd2320cd6f9a | 286:729b01914098 |
---|---|
25 char_I_deco_gas_change[gas-1] = depth; | 25 char_I_deco_gas_change[gas-1] = depth; |
26 | 26 |
27 DEFINE_GAS(1, 21, 0, 0, 1); // Gas#1 : Air FIRST | 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 | 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 | 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 | 30 DEFINE_GAS(4, 21, 0, 0, 0); // Gas#2 : air @ 10m DISABLED |
31 DEFINE_GAS(5, 21, 0, 40, 0); // Gas#2 : air @ 40m DISABLED | 31 DEFINE_GAS(5, 21, 0, 0, 0); // Gas#2 : air @ 40m DISABLED |
32 } | 32 } |
33 | 33 |
34 ////////////////////////////////////////////////////////////////////////////// | 34 ////////////////////////////////////////////////////////////////////////////// |
35 /// \brief Define a default deco plan. | 35 /// \brief Define a default deco plan. |
36 static void setup_plan() | 36 static void setup_plan() |
62 static void setup_dive(int bottom, int depth) | 62 static void setup_dive(int bottom, int depth) |
63 { | 63 { |
64 setup_gas(); | 64 setup_gas(); |
65 setup_plan(); | 65 setup_plan(); |
66 | 66 |
67 char_I_bottom_depth = bottom; | 67 char_I_bottom_depth = depth; |
68 char_I_bottom_time = depth; | 68 char_I_bottom_time = bottom; |
69 } | |
70 | |
71 ////////////////////////////////////////////////////////////////////////////// | |
72 /// \brief Gas consumption at a fixed depth | |
73 static float fixed(int rmv, int time, int depth) { | |
74 return rmv * time * (1 + 0.1f*depth); | |
75 } | |
76 | |
77 TEST(gas_volume, fixed) | |
78 { | |
79 EXPECT_EQ(20*30*1, fixed(20,30, 0)); // 30' @ 0m | |
80 EXPECT_EQ(20*30*5, fixed(20,30,40)); // 30' @ 40m | |
81 } | |
82 | |
83 ////////////////////////////////////////////////////////////////////////////// | |
84 /// \brief Gas consumption during an ascent at 10m/min. | |
85 static float ascent(int rmv, int oldDepth, int newDepth) | |
86 { | |
87 return rmv | |
88 * abs(oldDepth-newDepth)*0.1f // Ascent time | |
89 * (1 + 0.05f*(oldDepth + newDepth)); // Avg pressure. | |
90 } | |
91 | |
92 TEST(gas_volume, ascent) | |
93 { | |
94 EXPECT_EQ(0, ascent(20, 30, 30)); // 30m -> 30m : no time, no conso | |
95 EXPECT_EQ(20*4*(1+2), ascent(20, 40, 0)); // 40m -> 0m : 4min, avg 20m | |
96 EXPECT_EQ(20*4*(1+2), ascent(20, 0, 40)); // 0m -> 40m : 4min, avg 20m | |
69 } | 97 } |
70 | 98 |
71 ////////////////////////////////////////////////////////////////////////////// | 99 ////////////////////////////////////////////////////////////////////////////// |
72 | 100 |
73 TEST(gas_volume, run) | 101 TEST(gas_volume, 30min40m_no_stops) |
102 { | |
103 setup_dive(30, 40); // 30' @ 40m | |
104 for(int s=0; s<32; ++s) | |
105 char_O_deco_time[s] = 0; | |
106 | |
107 ASSERT_NO_THROW( deco_gas_volumes() ); | |
108 EXPECT_EQ(fixed(20,30,40) + ascent(20,40,0), | |
109 int_O_gas_volumes[0]); | |
110 EXPECT_EQ(0, int_O_gas_volumes[1]); | |
111 EXPECT_EQ(0, int_O_gas_volumes[2]); | |
112 EXPECT_EQ(0, int_O_gas_volumes[3]); | |
113 EXPECT_EQ(0, int_O_gas_volumes[4]); | |
114 } | |
115 | |
116 ////////////////////////////////////////////////////////////////////////////// | |
117 | |
118 TEST(gas_volume, 30min40m_1min_1min_3min_12min) | |
74 { | 119 { |
75 setup_dive(30, 40); // 30' @ 40m | 120 setup_dive(30, 40); // 30' @ 40m |
76 | 121 |
77 EXPECT_NO_THROW( deco_gas_volumes() ); | 122 ASSERT_NO_THROW( deco_gas_volumes() ); |
123 EXPECT_NEAR(fixed(20,30,40) + ascent(20,40,12) | |
124 + fixed(20, 1,12) + ascent(20,12,9), | |
125 int_O_gas_volumes[0], 1); | |
126 EXPECT_EQ(0, int_O_gas_volumes[1]); | |
127 EXPECT_NEAR(fixed(20, 1,9) + ascent(20,9,6) | |
128 + fixed(20, 3,6) + ascent(20,6,3) | |
129 + fixed(20,12,3) + ascent(20,3,0), | |
130 int_O_gas_volumes[2], 1); | |
131 EXPECT_EQ(0, int_O_gas_volumes[3]); | |
132 EXPECT_EQ(0, int_O_gas_volumes[4]); | |
78 } | 133 } |