[commands] C++ unique_ptr migration (#4319)

Add a CommandPtr with an internal unique_ptr to enable not needing to move the underlying classes, which is error-prone due to the potential for lambda captures.
This commit is contained in:
Starlight220
2022-10-06 01:19:28 +03:00
committed by GitHub
parent 3b81cf6c35
commit 60e29627c0
18 changed files with 644 additions and 133 deletions

View File

@@ -54,7 +54,7 @@ TEST_F(CommandRequirementsTest, RequirementUninterruptible) {
int exeCounter = 0;
int endCounter = 0;
std::unique_ptr<Command> command1 =
CommandPtr command1 =
FunctionalCommand([&initCounter] { initCounter++; },
[&exeCounter] { exeCounter++; },
[&endCounter](bool interruptible) { endCounter++; },
@@ -68,13 +68,13 @@ TEST_F(CommandRequirementsTest, RequirementUninterruptible) {
EXPECT_CALL(command2, End(true)).Times(0);
EXPECT_CALL(command2, End(false)).Times(0);
scheduler.Schedule(command1.get());
scheduler.Schedule(command1);
EXPECT_EQ(1, initCounter);
scheduler.Run();
EXPECT_EQ(1, exeCounter);
EXPECT_TRUE(scheduler.IsScheduled(command1.get()));
EXPECT_TRUE(scheduler.IsScheduled(command1));
scheduler.Schedule(&command2);
EXPECT_TRUE(scheduler.IsScheduled(command1.get()));
EXPECT_TRUE(scheduler.IsScheduled(command1));
EXPECT_FALSE(scheduler.IsScheduled(&command2));
scheduler.Run();
EXPECT_EQ(2, exeCounter);