添加测试

This commit is contained in:
2026-01-05 02:55:21 +08:00
parent 9d0790370f
commit 1f679551f2
20 changed files with 784 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
#include <gtest/gtest.h>
#include "undo/undostack.h"
#include "undo/undocommand.h"
namespace {
class TestCommand final : public olive::UndoCommand {
public:
explicit TestCommand(int *value)
: value_(value)
{
}
protected:
void redo() override
{
if (value_) {
(*value_)++;
}
}
void undo() override
{
if (value_) {
(*value_)--;
}
}
private:
int *value_ = nullptr;
};
}
TEST(UndoStack, PushUndoRedo)
{
int counter = 0;
olive::UndoStack stack;
stack.push(new TestCommand(&counter), QStringLiteral("Test"));
EXPECT_EQ(counter, 1);
stack.undo();
EXPECT_EQ(counter, 0);
stack.redo();
EXPECT_EQ(counter, 1);
}