-
Notifications
You must be signed in to change notification settings - Fork 173
Test cases for Fallbacks container #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
f2b12f1
f47f9c2
b98ee7f
514021c
414964a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ void append(ContainerBase& c, const std::initializer_list<StageType>& types) { | |
| } | ||
| } | ||
| } | ||
| constexpr double INF = std::numeric_limits<double>::infinity(); | ||
|
|
||
| class NamedStage : public GeneratorMockup | ||
| { | ||
|
|
@@ -685,3 +686,52 @@ TEST(Fallback, failing) { | |
| EXPECT_FALSE(t.plan()); | ||
| EXPECT_EQ(t.solutions().size(), 0u); | ||
| } | ||
|
|
||
| TEST(Fallback, ConnectStageInsideFallbacks) { | ||
|
||
| resetMockupIds(); | ||
| Task t; | ||
| t.setRobotModel(getModel()); | ||
|
|
||
| t.add(std::make_unique<GeneratorMockup>()); | ||
|
|
||
| auto fallbacks = std::make_unique<Fallbacks>("Fallbacks"); | ||
| fallbacks->add(std::make_unique<ConnectMockup>()); | ||
| t.add(std::move(fallbacks)); | ||
|
|
||
| t.add(std::make_unique<GeneratorMockup>()); | ||
|
|
||
| EXPECT_TRUE(t.plan()); | ||
| EXPECT_EQ(t.numSolutions(), 1u); | ||
| } | ||
|
|
||
| TEST(Fallback, ComputeFirstSuccessfulStageOnly) { | ||
| resetMockupIds(); | ||
| Task t; | ||
| t.setRobotModel(getModel()); | ||
|
|
||
| t.add(std::make_unique<GeneratorMockup>()); | ||
|
|
||
| auto fallbacks = std::make_unique<Fallbacks>("Fallbacks"); | ||
| fallbacks->add(std::make_unique<ForwardMockup>(PredefinedCosts::constant(0.0))); | ||
| fallbacks->add(std::make_unique<ForwardMockup>(PredefinedCosts::constant(0.0))); | ||
| t.add(std::move(fallbacks)); | ||
|
|
||
| EXPECT_TRUE(t.plan()); | ||
| EXPECT_EQ(t.numSolutions(), 1u); | ||
| } | ||
|
|
||
| TEST(Fallback, ActiveChildReset) { | ||
| resetMockupIds(); | ||
| Task t; | ||
| t.setRobotModel(getModel()); | ||
|
|
||
| t.add(std::make_unique<GeneratorMockup>(PredefinedCosts{ { 0.0, INF, 0.0 } })); | ||
|
|
||
| auto fallbacks = std::make_unique<Fallbacks>("Fallbacks"); | ||
| fallbacks->add(std::make_unique<ForwardMockup>(PredefinedCosts::constant(0.0))); | ||
| fallbacks->add(std::make_unique<ForwardMockup>(PredefinedCosts::constant(0.0))); | ||
| t.add(std::move(fallbacks)); | ||
|
|
||
| EXPECT_TRUE(t.plan()); | ||
| EXPECT_EQ(t.numSolutions(), 4u); | ||
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch does not make any sense to me.
If the generator in ComputeFirstSuccessfulStageOnly would spawn multiple solutions, I would still expect a solution from the first child for each of the inputs! Otherwise you prune too many computation branches and loose solutions.