mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[commands] Add property tests for command compositions (#4715)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "CommandTestBase.h"
|
||||
#include "CompositionTestBase.h"
|
||||
#include "frc2/command/InstantCommand.h"
|
||||
#include "frc2/command/ParallelDeadlineGroup.h"
|
||||
#include "frc2/command/WaitUntilCommand.h"
|
||||
@@ -131,3 +132,23 @@ TEST_F(ParallelDeadlineGroupTest, ParallelDeadlineRequirement) {
|
||||
EXPECT_TRUE(scheduler.IsScheduled(&command3));
|
||||
EXPECT_FALSE(scheduler.IsScheduled(&group));
|
||||
}
|
||||
|
||||
class TestableDeadlineCommand : public ParallelDeadlineGroup {
|
||||
static ParallelDeadlineGroup ToCommand(
|
||||
std::vector<std::unique_ptr<Command>>&& commands) {
|
||||
std::vector<std::unique_ptr<Command>> vec;
|
||||
std::unique_ptr<Command> deadline = std::move(commands[0]);
|
||||
for (unsigned int i = 1; i < commands.size(); i++) {
|
||||
vec.emplace_back(std::move(commands[i]));
|
||||
}
|
||||
return ParallelDeadlineGroup(std::move(deadline), std::move(vec));
|
||||
}
|
||||
|
||||
public:
|
||||
explicit TestableDeadlineCommand(
|
||||
std::vector<std::unique_ptr<Command>>&& commands)
|
||||
: ParallelDeadlineGroup(ToCommand(std::move(commands))) {}
|
||||
};
|
||||
|
||||
INSTANTIATE_MULTI_COMMAND_COMPOSITION_TEST_SUITE(ParallelDeadlineGroupTest,
|
||||
TestableDeadlineCommand);
|
||||
|
||||
Reference in New Issue
Block a user