Skip to content

Commit c404c4e

Browse files
committed
Add test
1 parent 10ea557 commit c404c4e

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

test/mobility/Test_dynamics.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,27 @@ TEST_CASE("FirstOrderDynamics") {
425425
}
426426
}
427427
}
428+
GIVEN("A disconnected graph") {
429+
Street s1{0, std::make_pair(0, 1), 10.};
430+
RoadNetwork graph;
431+
graph.addStreets(s1);
432+
FirstOrderDynamics dynamics{graph, false, 69, 0., dsf::PathWeight::LENGTH};
433+
434+
WHEN(
435+
"We add an impossible itinerary (to source node) and update paths with "
436+
"throw_on_empty=true") {
437+
dynamics.addItinerary(std::unique_ptr<Itinerary>(new Itinerary(0, 0)));
438+
THEN("It throws an exception") { CHECK_THROWS(dynamics.updatePaths(true)); }
439+
}
440+
441+
WHEN(
442+
"We add an impossible itinerary (to source node) and update paths with "
443+
"throw_on_empty=false") {
444+
dynamics.addItinerary(std::unique_ptr<Itinerary>(new Itinerary(0, 0)));
445+
dynamics.updatePaths(false);
446+
THEN("The itinerary is removed") { CHECK(dynamics.itineraries().empty()); }
447+
}
448+
}
428449
}
429450
SUBCASE("Evolve") {
430451
GIVEN("A dynamics object and an itinerary") {
@@ -549,7 +570,7 @@ TEST_CASE("FirstOrderDynamics") {
549570
}
550571
}
551572
GIVEN("A simple network and an agent with forced itinerary") {
552-
spdlog::set_level(spdlog::level::trace);
573+
// spdlog::set_level(spdlog::level::trace);
553574
Street s0_1{1, std::make_pair(0, 1), 30., 15.};
554575
Street s1_0{3, std::make_pair(1, 0), 30., 15.};
555576
Street s1_2{5, std::make_pair(1, 2), 30., 15.};
@@ -586,7 +607,7 @@ TEST_CASE("FirstOrderDynamics") {
586607
CHECK_EQ(dynamics.nAgents(), 0);
587608
}
588609
}
589-
spdlog::set_level(spdlog::level::info);
610+
// spdlog::set_level(spdlog::level::info);
590611
}
591612
}
592613
SUBCASE("TrafficLights") {

0 commit comments

Comments
 (0)