[commands] Add property tests for command compositions (#4715)

This commit is contained in:
Starlight220
2022-11-28 02:23:56 +02:00
committed by GitHub
parent e4ac09077c
commit 8958b2a4da
31 changed files with 579 additions and 59 deletions

View File

@@ -56,6 +56,11 @@ bool ParallelCommandGroup::RunsWhenDisabled() const {
return m_runWhenDisabled;
}
Command::InterruptionBehavior ParallelCommandGroup::GetInterruptionBehavior()
const {
return m_interruptBehavior;
}
void ParallelCommandGroup::AddCommands(
std::vector<std::unique_ptr<Command>>&& commands) {
for (auto&& command : commands) {
@@ -75,6 +80,10 @@ void ParallelCommandGroup::AddCommands(
command->SetGrouped(true);
AddRequirements(command->GetRequirements());
m_runWhenDisabled &= command->RunsWhenDisabled();
if (command->GetInterruptionBehavior() ==
Command::InterruptionBehavior::kCancelSelf) {
m_interruptBehavior = Command::InterruptionBehavior::kCancelSelf;
}
m_commands.emplace_back(std::move(command), false);
} else {
throw FRC_MakeError(frc::err::CommandIllegalUse,

View File

@@ -53,6 +53,11 @@ bool ParallelDeadlineGroup::RunsWhenDisabled() const {
return m_runWhenDisabled;
}
Command::InterruptionBehavior ParallelDeadlineGroup::GetInterruptionBehavior()
const {
return m_interruptBehavior;
}
void ParallelDeadlineGroup::AddCommands(
std::vector<std::unique_ptr<Command>>&& commands) {
if (!RequireUngrouped(commands)) {
@@ -70,6 +75,10 @@ void ParallelDeadlineGroup::AddCommands(
command->SetGrouped(true);
AddRequirements(command->GetRequirements());
m_runWhenDisabled &= command->RunsWhenDisabled();
if (command->GetInterruptionBehavior() ==
Command::InterruptionBehavior::kCancelSelf) {
m_interruptBehavior = Command::InterruptionBehavior::kCancelSelf;
}
m_commands.emplace_back(std::move(command), false);
} else {
throw FRC_MakeError(frc::err::CommandIllegalUse,

View File

@@ -43,6 +43,11 @@ bool ParallelRaceGroup::RunsWhenDisabled() const {
return m_runWhenDisabled;
}
Command::InterruptionBehavior ParallelRaceGroup::GetInterruptionBehavior()
const {
return m_interruptBehavior;
}
void ParallelRaceGroup::AddCommands(
std::vector<std::unique_ptr<Command>>&& commands) {
if (!RequireUngrouped(commands)) {
@@ -60,6 +65,10 @@ void ParallelRaceGroup::AddCommands(
command->SetGrouped(true);
AddRequirements(command->GetRequirements());
m_runWhenDisabled &= command->RunsWhenDisabled();
if (command->GetInterruptionBehavior() ==
Command::InterruptionBehavior::kCancelSelf) {
m_interruptBehavior = Command::InterruptionBehavior::kCancelSelf;
}
m_commands.emplace_back(std::move(command));
} else {
throw FRC_MakeError(frc::err::CommandIllegalUse,

View File

@@ -53,6 +53,11 @@ bool SequentialCommandGroup::RunsWhenDisabled() const {
return m_runWhenDisabled;
}
Command::InterruptionBehavior SequentialCommandGroup::GetInterruptionBehavior()
const {
return m_interruptBehavior;
}
void SequentialCommandGroup::AddCommands(
std::vector<std::unique_ptr<Command>>&& commands) {
if (!RequireUngrouped(commands)) {
@@ -69,6 +74,10 @@ void SequentialCommandGroup::AddCommands(
command->SetGrouped(true);
AddRequirements(command->GetRequirements());
m_runWhenDisabled &= command->RunsWhenDisabled();
if (command->GetInterruptionBehavior() ==
Command::InterruptionBehavior::kCancelSelf) {
m_interruptBehavior = Command::InterruptionBehavior::kCancelSelf;
}
m_commands.emplace_back(std::move(command));
}
}