Files
allwpilib/commandsv2/src/test/native/cpp/wpi/command/StartEndCommandTest.cpp

27 lines
739 B
C++
Raw Normal View History

// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
2025-11-07 19:56:21 -05:00
#include "CommandTestBase.hpp"
2025-11-07 19:57:55 -05:00
#include "wpi/commands2/Commands.hpp"
2025-11-07 19:56:21 -05:00
#include "wpi/commands2/StartEndCommand.hpp"
2025-11-07 20:00:05 -05:00
using namespace wpi::cmd;
class StartEndCommandTest : public CommandTestBase {};
TEST_F(StartEndCommandTest, StartEndCommandSchedule) {
CommandScheduler scheduler = GetScheduler();
int counter = 0;
auto command =
cmd::StartEnd([&counter] { counter++; }, [&counter] { counter++; });
scheduler.Schedule(command);
scheduler.Run();
scheduler.Run();
scheduler.Cancel(command);
EXPECT_EQ(2, counter);
}