22 #include <fake_clock.hh> 34 TEST_CASE(
"AddressPool's can be constructed.",
"[AddressPool]")
41 TEST_CASE(
"AddressPool's 'add' method adds an address to the pool.",
44 SECTION(
"With fake_clock.")
51 std::sort(addr.begin(), addr.end(), std::greater<MAVAddress>());
52 REQUIRE(addr.size() == 3);
53 std::vector<MAVAddress> compare =
59 REQUIRE(addr == compare);
61 SECTION(
"With std::chrono::steady_clock.")
68 std::sort(addr.begin(), addr.end(), std::greater<MAVAddress>());
69 REQUIRE(addr.size() == 3);
70 std::vector<MAVAddress> compare =
76 REQUIRE(addr == compare);
81 TEST_CASE(
"AddressPool's 'contains' method determines whether an address is " 82 "in the pool or not.",
"[AddressPool]")
84 SECTION(
"With fake_clock.")
95 SECTION(
"With std::chrono::steady_clock.")
109 TEST_CASE(
"AddressPool removes expired addresses.",
"[AddressPool]")
111 SECTION(
"When using the 'contains' method (and default timeout of 2 min).")
115 fake_clock::advance(1s);
117 fake_clock::advance(1s);
119 fake_clock::advance(1s);
125 fake_clock::advance(117s);
130 fake_clock::advance(1s);
135 fake_clock::advance(1s);
140 fake_clock::advance(1s);
145 fake_clock::advance(1s);
151 SECTION(
"When using the 'contains' method (and a custom timeout).")
155 fake_clock::advance(1s);
157 fake_clock::advance(1s);
159 fake_clock::advance(1s);
165 fake_clock::advance(3597s);
170 fake_clock::advance(1s);
175 fake_clock::advance(1s);
180 fake_clock::advance(1s);
185 fake_clock::advance(1s);
191 SECTION(
"When using the 'addresses' method (and default timeout of 2 min).")
195 fake_clock::advance(1s);
197 fake_clock::advance(1s);
199 fake_clock::advance(1s);
202 std::vector<MAVAddress> vec =
210 std::sort(addr.begin(), addr.end());
211 REQUIRE(vec == addr);
213 fake_clock::advance(117s);
215 std::vector<MAVAddress> vec =
223 std::sort(addr.begin(), addr.end());
224 REQUIRE(vec == addr);
226 fake_clock::advance(1s);
228 std::vector<MAVAddress> vec =
235 std::sort(addr.begin(), addr.end());
236 REQUIRE(vec == addr);
238 fake_clock::advance(1s);
240 std::vector<MAVAddress> vec =
246 std::sort(addr.begin(), addr.end());
247 REQUIRE(vec == addr);
249 fake_clock::advance(1s);
251 std::vector<MAVAddress> vec =
256 std::sort(addr.begin(), addr.end());
257 REQUIRE(vec == addr);
259 fake_clock::advance(1s);
261 std::vector<MAVAddress> vec;
265 SECTION(
"When using the 'addresses' method (and a custom timeout).")
269 fake_clock::advance(1s);
271 fake_clock::advance(1s);
273 fake_clock::advance(1s);
276 std::vector<MAVAddress> vec =
284 std::sort(addr.begin(), addr.end());
285 REQUIRE(vec == addr);
287 fake_clock::advance(3597s);
289 std::vector<MAVAddress> vec =
297 std::sort(addr.begin(), addr.end());
298 REQUIRE(vec == addr);
300 fake_clock::advance(1s);
302 std::vector<MAVAddress> vec =
309 std::sort(addr.begin(), addr.end());
310 REQUIRE(vec == addr);
312 fake_clock::advance(1s);
314 std::vector<MAVAddress> vec =
320 std::sort(addr.begin(), addr.end());
321 REQUIRE(vec == addr);
323 fake_clock::advance(1s);
325 std::vector<MAVAddress> vec =
330 std::sort(addr.begin(), addr.end());
331 REQUIRE(vec == addr);
333 fake_clock::advance(1s);
335 std::vector<MAVAddress> vec;
TEST_VIRTUAL void add(MAVAddress address)
TEST_CASE("AddressPool's can be constructed.", "[AddressPool]")
TEST_VIRTUAL bool contains(const MAVAddress &address)
TEST_VIRTUAL std::vector< MAVAddress > addresses()