[commands] Use factories and decorators in Command tests (#7006)

This commit is contained in:
ハイドラント
2024-12-29 10:45:17 -06:00
committed by GitHub
parent e7dd5dca82
commit 78b6d61e88
30 changed files with 374 additions and 412 deletions

View File

@@ -48,18 +48,19 @@ TEST_F(SelectCommandTest, SelectCommandRequirement) {
TestSubsystem requirement3;
TestSubsystem requirement4;
InstantCommand command1([] {}, {&requirement1, &requirement2});
InstantCommand command2([] {}, {&requirement3});
InstantCommand command3([] {}, {&requirement3, &requirement4});
auto command1 = cmd::RunOnce([] {}, {&requirement1, &requirement2});
auto command2 = cmd::RunOnce([] {}, {&requirement3});
auto command3 = cmd::RunOnce([] {}, {&requirement3, &requirement4});
SelectCommand<int> select([] { return 1; }, std::pair(1, std::move(command1)),
std::pair(2, std::move(command2)));
auto select =
cmd::Select<int>([] { return 1; }, std::pair(1, std::move(command1)),
std::pair(2, std::move(command2)));
scheduler.Schedule(&select);
scheduler.Schedule(&command3);
scheduler.Schedule(select);
scheduler.Schedule(command3);
EXPECT_TRUE(scheduler.IsScheduled(&command3));
EXPECT_FALSE(scheduler.IsScheduled(&select));
EXPECT_TRUE(scheduler.IsScheduled(command3));
EXPECT_FALSE(scheduler.IsScheduled(select));
}
class TestableSelectCommand : public SelectCommand<int> {