add unit test for coalescing erase change units within a change operation
This commit is contained in:
parent
3b1bea80aa
commit
861aaed940
@ -137,7 +137,9 @@ public:
|
|||||||
void undo();
|
void undo();
|
||||||
void redo();
|
void redo();
|
||||||
|
|
||||||
|
#ifndef ENABLE_TESTING
|
||||||
protected:
|
protected:
|
||||||
|
#endif
|
||||||
bool m_eol_at_eof;
|
bool m_eol_at_eof;
|
||||||
LineEndings::Type m_line_endings;
|
LineEndings::Type m_line_endings;
|
||||||
std::shared_ptr<GapBuffer> m_gap_buffer;
|
std::shared_ptr<GapBuffer> m_gap_buffer;
|
||||||
|
@ -242,3 +242,27 @@ TEST(BufferTest, allows_undo_and_redo_of_erases)
|
|||||||
EXPECT_EQ(ss("bc\ndfghi\n"), b.get_string());
|
EXPECT_EQ(ss("bc\ndfghi\n"), b.get_string());
|
||||||
EXPECT_EQ(C('f'), **it);
|
EXPECT_EQ(C('f'), **it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(BufferTest, erase_chunks_are_coalesced_within_a_change_operation)
|
||||||
|
{
|
||||||
|
std::string s("abcdef\n");
|
||||||
|
Buffer b((const uint8_t *)&s[0], s.size());
|
||||||
|
auto it = b.add_cursor();
|
||||||
|
|
||||||
|
b.enter_insert_mode();
|
||||||
|
it->go_right_in_line(false);
|
||||||
|
it->go_right_in_line(false); /* erase just after previous erase */
|
||||||
|
b.erase_code_point(*it);
|
||||||
|
b.erase_code_point(*it);
|
||||||
|
it->go_left_in_line();
|
||||||
|
b.erase_code_point(*it); /* erase just before previous erase */
|
||||||
|
b.exit_insert_mode();
|
||||||
|
EXPECT_EQ(C('e'), **it);
|
||||||
|
EXPECT_EQ(ss("aef\n"), b.get_string());
|
||||||
|
ASSERT_EQ(1u, b.m_change_operations.size());
|
||||||
|
ASSERT_EQ(1u, b.m_change_operations[0]->changes.size());
|
||||||
|
|
||||||
|
b.undo();
|
||||||
|
EXPECT_EQ(C('e'), **it);
|
||||||
|
EXPECT_EQ(ss("abcdef\n"), b.get_string());
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user