test(editor): add unit tests for editor command classes - #501
Conversation
There was a problem hiding this comment.
Sorry @pengfeixx, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Reviewer's GuideAdd focused unit tests for editor command and UI helper classes to cover previously untested undo/redo logic, destructor behavior, and mouse interaction paths in the editor module. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Add tests for ChangeMarkCommand, EndlineFormartCommand, IndentTextCommand, LineNumberArea and UndoList. Log: 新增editor模块命令类的单元测试 Influence: 覆盖编辑器撤销/重做命令类的未覆盖函数
a38605a to
6447806
Compare
Log: 修正新增测试文件的SPDX版权头年份 Influence: 无
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 以 ut_undolist.cpp 为例,展示如何使用 SetUp/TearDown 减少重复代码
#include "gtest/gtest.h"
#include "../../src/editor/undolist.h"
#include "../../src/editor/indenttextcommond.h"
#include "../../src/editor/dtextedit.h"
#include "../stub.h"
class UT_UndoList : public ::testing::Test {
protected:
void SetUp() override {
list = new UndoList;
edit = new TextEdit;
edit->setPlainText("aaa\nbbb");
QTextCursor c = edit->textCursor();
c.setPosition(0);
edit->setTextCursor(c);
}
void TearDown() override {
delete list;
delete edit;
}
UndoList *list;
TextEdit *edit;
};
TEST_F(UT_UndoList, constructor_and_destructor)
{
ASSERT_TRUE(list != nullptr);
}
TEST_F(UT_UndoList, destructor_with_children)
{
list->appendCom(new IndentTextCommand(edit, 0, 0, 0, 0));
list->appendCom(new IndentTextCommand(edit, 0, 0, 0, 0));
list->appendCom(nullptr);
}
TEST_F(UT_UndoList, undo_redo)
{
list->appendCom(new IndentTextCommand(edit, 0, 0, 0, 0));
list->redo();
list->undo();
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
Add tests for ChangeMarkCommand, EndlineFormartCommand, IndentTextCommand, LineNumberArea and UndoList.
Log: 新增editor模块命令类的单元测试
Influence: 覆盖编辑器撤销/重做命令类的未覆盖函数
Summary by Sourcery
Add unit tests for editor command and UI helper classes to improve undo/redo and interaction coverage.
Tests: