mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[commands] Use factories and decorators in Command tests (#7006)
This commit is contained in:
@@ -56,85 +56,72 @@ TEST_F(ConditionalCommandTest, ConditionalCommandRequirement) {
|
||||
}
|
||||
|
||||
TEST_F(ConditionalCommandTest, AllTrue) {
|
||||
CommandPtr command =
|
||||
cmd::Either(cmd::WaitUntil([] { return false; }).IgnoringDisable(true),
|
||||
cmd::WaitUntil([] { return false; }).IgnoringDisable(true),
|
||||
[] { return true; });
|
||||
auto command =
|
||||
cmd::Either(cmd::Idle().IgnoringDisable(true),
|
||||
cmd::Idle().IgnoringDisable(true), [] { return true; });
|
||||
EXPECT_EQ(true, command.get()->RunsWhenDisabled());
|
||||
}
|
||||
|
||||
TEST_F(ConditionalCommandTest, AllFalse) {
|
||||
CommandPtr command =
|
||||
cmd::Either(cmd::WaitUntil([] { return false; }).IgnoringDisable(false),
|
||||
cmd::WaitUntil([] { return false; }).IgnoringDisable(false),
|
||||
[] { return true; });
|
||||
auto command =
|
||||
cmd::Either(cmd::Idle().IgnoringDisable(false),
|
||||
cmd::Idle().IgnoringDisable(false), [] { return true; });
|
||||
EXPECT_EQ(false, command.get()->RunsWhenDisabled());
|
||||
}
|
||||
|
||||
TEST_F(ConditionalCommandTest, OneTrueOneFalse) {
|
||||
CommandPtr command =
|
||||
cmd::Either(cmd::WaitUntil([] { return false; }).IgnoringDisable(true),
|
||||
cmd::WaitUntil([] { return false; }).IgnoringDisable(false),
|
||||
[] { return true; });
|
||||
auto command =
|
||||
cmd::Either(cmd::Idle().IgnoringDisable(true),
|
||||
cmd::Idle().IgnoringDisable(false), [] { return true; });
|
||||
EXPECT_EQ(false, command.get()->RunsWhenDisabled());
|
||||
}
|
||||
|
||||
TEST_F(ConditionalCommandTest, TwoFalseOneTrue) {
|
||||
CommandPtr command =
|
||||
cmd::Either(cmd::WaitUntil([] { return false; }).IgnoringDisable(false),
|
||||
cmd::WaitUntil([] { return false; }).IgnoringDisable(true),
|
||||
[] { return true; });
|
||||
auto command =
|
||||
cmd::Either(cmd::Idle().IgnoringDisable(false),
|
||||
cmd::Idle().IgnoringDisable(true), [] { return true; });
|
||||
EXPECT_EQ(false, command.get()->RunsWhenDisabled());
|
||||
}
|
||||
|
||||
TEST_F(ConditionalCommandTest, AllCancelSelf) {
|
||||
CommandPtr command = cmd::Either(
|
||||
cmd::WaitUntil([] {
|
||||
return false;
|
||||
}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf),
|
||||
cmd::WaitUntil([] {
|
||||
return false;
|
||||
}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf),
|
||||
[] { return true; });
|
||||
auto command = cmd::Either(cmd::Idle().WithInterruptBehavior(
|
||||
Command::InterruptionBehavior::kCancelSelf),
|
||||
cmd::Idle().WithInterruptBehavior(
|
||||
Command::InterruptionBehavior::kCancelSelf),
|
||||
[] { return true; });
|
||||
EXPECT_EQ(Command::InterruptionBehavior::kCancelSelf,
|
||||
command.get()->GetInterruptionBehavior());
|
||||
}
|
||||
|
||||
TEST_F(ConditionalCommandTest, AllCancelIncoming) {
|
||||
CommandPtr command = cmd::Either(
|
||||
cmd::WaitUntil([] {
|
||||
return false;
|
||||
}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming),
|
||||
cmd::WaitUntil([] {
|
||||
return false;
|
||||
}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming),
|
||||
[] { return false; });
|
||||
auto command =
|
||||
cmd::Either(cmd::Idle().WithInterruptBehavior(
|
||||
Command::InterruptionBehavior::kCancelIncoming),
|
||||
cmd::Idle().WithInterruptBehavior(
|
||||
Command::InterruptionBehavior::kCancelIncoming),
|
||||
[] { return false; });
|
||||
EXPECT_EQ(Command::InterruptionBehavior::kCancelIncoming,
|
||||
command.get()->GetInterruptionBehavior());
|
||||
}
|
||||
|
||||
TEST_F(ConditionalCommandTest, OneCancelSelfOneIncoming) {
|
||||
CommandPtr command = cmd::Either(
|
||||
cmd::WaitUntil([] {
|
||||
return false;
|
||||
}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf),
|
||||
cmd::WaitUntil([] {
|
||||
return false;
|
||||
}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming),
|
||||
[] { return false; });
|
||||
auto command =
|
||||
cmd::Either(cmd::Idle().WithInterruptBehavior(
|
||||
Command::InterruptionBehavior::kCancelSelf),
|
||||
cmd::Idle().WithInterruptBehavior(
|
||||
Command::InterruptionBehavior::kCancelIncoming),
|
||||
[] { return false; });
|
||||
EXPECT_EQ(Command::InterruptionBehavior::kCancelSelf,
|
||||
command.get()->GetInterruptionBehavior());
|
||||
}
|
||||
|
||||
TEST_F(ConditionalCommandTest, OneCancelIncomingOneSelf) {
|
||||
CommandPtr command = cmd::Either(
|
||||
cmd::WaitUntil([] {
|
||||
return false;
|
||||
}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelIncoming),
|
||||
cmd::WaitUntil([] {
|
||||
return false;
|
||||
}).WithInterruptBehavior(Command::InterruptionBehavior::kCancelSelf),
|
||||
[] { return false; });
|
||||
auto command =
|
||||
cmd::Either(cmd::Idle().WithInterruptBehavior(
|
||||
Command::InterruptionBehavior::kCancelIncoming),
|
||||
cmd::Idle().WithInterruptBehavior(
|
||||
Command::InterruptionBehavior::kCancelSelf),
|
||||
[] { return false; });
|
||||
EXPECT_EQ(Command::InterruptionBehavior::kCancelSelf,
|
||||
command.get()->GetInterruptionBehavior());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user