|
5 | 5 | #include <string> |
6 | 6 | #include <chrono> |
7 | 7 |
|
| 8 | + |
8 | 9 | using namespace std::chrono; |
9 | 10 |
|
10 | 11 | using namespace Microsoft::VisualStudio::CppUnitTestFramework; |
@@ -166,12 +167,60 @@ namespace BeluxPluginTest |
166 | 167 | Assert::AreEqual(std::string("LNO7E"), maybe_sid->sid); |
167 | 168 | } |
168 | 169 |
|
169 | | - TEST_METHOD(RespectsTiemZones) |
| 170 | + TEST_METHOD(RespectsTimeZonesPositive) |
170 | 171 | { |
| 172 | + // DENUT7N gets assigned for RWY19, if between 2345 and 0344L, or 25R is not active. |
| 173 | + // We will test with 25R active of course |
| 174 | + |
| 175 | + const auto allocator = get_filled_allocator(); |
| 176 | + |
| 177 | + // This is local. October 1st is winter time, so at 01:05L it should be active. This is 2305Z, so not active if incorrectly converted. |
| 178 | + tm fake_now{}; |
| 179 | + fake_now.tm_mday = 2; |
| 180 | + fake_now.tm_mon = 9; // October, somehow |
| 181 | + fake_now.tm_year = 2023 - 1900; |
| 182 | + fake_now.tm_hour = 1; |
| 183 | + fake_now.tm_min = 5; |
| 184 | + fake_now.tm_isdst = -1; |
| 185 | + const time_t epoch = mktime(&fake_now); |
| 186 | + Assert::IsTrue(epoch > 0); |
| 187 | + const auto clock = system_clock::from_time_t(epoch); |
| 188 | + |
| 189 | + const LaraParser parser = get_filled_lara(); |
| 190 | + const auto active = parser.get_active(fake_now); |
| 191 | + |
| 192 | + const auto maybe_sid = allocator.find("EBBR", "DENUT", "EDDF", 2, "19", clock, active, std::vector<std::string>{"25R"}); |
| 193 | + Assert::IsTrue(maybe_sid.has_value()); |
| 194 | + Assert::AreEqual(std::string("DENUT7N"), maybe_sid->sid); |
171 | 195 | } |
172 | 196 |
|
173 | | - TEST_METHOD(RespectsDisallowedRunways) |
| 197 | + TEST_METHOD(RespectsTimeZonesNegative) |
174 | 198 | { |
| 199 | + // DENUT7N gets assigned for RWY19, if between 2345 and 0344L, or 25R is not active. |
| 200 | + // We will test with 25R active of course |
| 201 | + // This also tests that it respects the 25R being disallowed, otherwise we'd get that |
| 202 | + // Instead we select DENUT1F, which is F-ictional |
| 203 | + |
| 204 | + const auto allocator = get_filled_allocator(); |
| 205 | + |
| 206 | + // This is local. October 1st is winter time, so at 03:50L it should not be active. This is 0150Z, so active if incorrectly converted. |
| 207 | + tm fake_now{}; |
| 208 | + fake_now.tm_mday = 2; |
| 209 | + fake_now.tm_mon = 9; // October, somehow |
| 210 | + fake_now.tm_year = 2023 - 1900; |
| 211 | + fake_now.tm_hour = 3; |
| 212 | + fake_now.tm_min = 50; |
| 213 | + fake_now.tm_isdst = -1; |
| 214 | + const time_t epoch = mktime(&fake_now); |
| 215 | + Assert::IsTrue(epoch > 0); |
| 216 | + const auto clock = system_clock::from_time_t(epoch); |
| 217 | + |
| 218 | + const LaraParser parser = get_filled_lara(); |
| 219 | + const auto active = parser.get_active(fake_now); |
| 220 | + |
| 221 | + const auto maybe_sid = allocator.find("EBBR", "DENUT", "EDDF", 2, "19", clock, active, std::vector<std::string>{"25R"}); |
| 222 | + Assert::IsTrue(maybe_sid.has_value()); |
| 223 | + Assert::AreNotEqual(std::string("DENUT7N"), maybe_sid->sid); |
175 | 224 | } |
176 | 225 | }; |
177 | 226 | } |
0 commit comments