add unit tests for buffer insert/erase character
This commit is contained in:
1 parent
21ba393c45
commit
e98454c771
3 files changed
+68
-24
No files matched your search
+15
-7
@@ -8,39 +8,47 @@
|
||||
|
||||
Buffer::Buffer()
|
||||
{
|
||||
common_pre_load_initialization();
|
||||
load_empty_buffer();
|
||||
common_initialization();
|
||||
common_post_load_initialization();
|
||||
}
|
||||
|
||||
Buffer::Buffer(const char * filename)
|
||||
{
|
||||
common_pre_load_initialization();
|
||||
if (!load_from_file(filename))
|
||||
{
|
||||
load_empty_buffer();
|
||||
}
|
||||
common_initialization();
|
||||
common_post_load_initialization();
|
||||
}
|
||||
|
||||
Buffer::Buffer(const uint8_t * data, size_t data_length)
|
||||
{
|
||||
common_pre_load_initialization();
|
||||
if (!load_from_memory(data, data_length))
|
||||
{
|
||||
load_empty_buffer();
|
||||
}
|
||||
common_initialization();
|
||||
common_post_load_initialization();
|
||||
}
|
||||
|
||||
void Buffer::common_initialization()
|
||||
void Buffer::common_pre_load_initialization()
|
||||
{
|
||||
m_tabstop = 4u;
|
||||
m_change_buffer = std::make_shared<GapBuffer>();
|
||||
m_operation_level = 0;
|
||||
m_current_change_operation_index = INVALID_CHANGE_OPERATION_INDEX;
|
||||
m_encoding = Encoding::UTF_8;
|
||||
}
|
||||
|
||||
void Buffer::common_post_load_initialization()
|
||||
{
|
||||
m_eof_iterator = add_iterator();
|
||||
while (m_eof_iterator->valid())
|
||||
{
|
||||
m_eof_iterator->go_forward();
|
||||
}
|
||||
m_change_buffer = std::make_shared<GapBuffer>();
|
||||
m_operation_level = 0;
|
||||
m_current_change_operation_index = INVALID_CHANGE_OPERATION_INDEX;
|
||||
}
|
||||
|
||||
void Buffer::load_empty_buffer()
|
||||
|
||||
+2
-1
@@ -154,7 +154,8 @@ protected:
|
||||
size_t m_current_change_operation_index;
|
||||
std::vector<std::shared_ptr<ChangeOperation>> m_change_operations;
|
||||
|
||||
void common_initialization();
|
||||
void common_pre_load_initialization();
|
||||
void common_post_load_initialization();
|
||||
bool load_from_file(const char * filename);
|
||||
void load_empty_buffer();
|
||||
bool load_from_memory(const uint8_t * data, size_t data_length);
|
||||
|
||||
Reference in new issue
Block a user