add more asserts
This commit is contained in:
parent
f14bc5e310
commit
3404366b65
|
@ -245,7 +245,8 @@ void Buffer::check_invariant() const
|
||||||
|
|
||||||
void Buffer::do_insert(const BufferIterator& pos, const String& content)
|
void Buffer::do_insert(const BufferIterator& pos, const String& content)
|
||||||
{
|
{
|
||||||
assert(pos.is_end() or utf8::is_character_start(pos));
|
assert(pos.is_valid() and (pos.is_end() or utf8::is_character_start(pos)));
|
||||||
|
assert(not contains(content, '\0'));
|
||||||
++m_timestamp;
|
++m_timestamp;
|
||||||
ByteCount offset = pos.offset();
|
ByteCount offset = pos.offset();
|
||||||
|
|
||||||
|
@ -322,6 +323,8 @@ void Buffer::do_insert(const BufferIterator& pos, const String& content)
|
||||||
|
|
||||||
void Buffer::do_erase(const BufferIterator& begin, const BufferIterator& end)
|
void Buffer::do_erase(const BufferIterator& begin, const BufferIterator& end)
|
||||||
{
|
{
|
||||||
|
assert(begin.is_valid());
|
||||||
|
assert(end.is_valid());
|
||||||
assert(utf8::is_character_start(begin) and
|
assert(utf8::is_character_start(begin) and
|
||||||
(end.is_end() or utf8::is_character_start(end)));
|
(end.is_end() or utf8::is_character_start(end)));
|
||||||
++m_timestamp;
|
++m_timestamp;
|
||||||
|
|
|
@ -64,7 +64,10 @@ DynamicSelectionList& DynamicSelectionList::operator=(SelectionList selections)
|
||||||
void DynamicSelectionList::check_invariant() const
|
void DynamicSelectionList::check_invariant() const
|
||||||
{
|
{
|
||||||
for (auto& sel : *this)
|
for (auto& sel : *this)
|
||||||
|
{
|
||||||
assert(m_buffer == &sel.buffer());
|
assert(m_buffer == &sel.buffer());
|
||||||
|
sel.check_invariant();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicSelectionList::on_insert(const BufferIterator& begin, const BufferIterator& end)
|
void DynamicSelectionList::on_insert(const BufferIterator& begin, const BufferIterator& end)
|
||||||
|
@ -73,7 +76,6 @@ void DynamicSelectionList::on_insert(const BufferIterator& begin, const BufferIt
|
||||||
{
|
{
|
||||||
sel.first().on_insert(begin.coord(), end.coord());
|
sel.first().on_insert(begin.coord(), end.coord());
|
||||||
sel.last().on_insert(begin.coord(), end.coord());
|
sel.last().on_insert(begin.coord(), end.coord());
|
||||||
sel.check_invariant();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +85,6 @@ void DynamicSelectionList::on_erase(const BufferIterator& begin, const BufferIte
|
||||||
{
|
{
|
||||||
sel.first().on_erase(begin.coord(), end.coord());
|
sel.first().on_erase(begin.coord(), end.coord());
|
||||||
sel.last().on_erase(begin.coord(), end.coord());
|
sel.last().on_erase(begin.coord(), end.coord());
|
||||||
sel.check_invariant();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -334,12 +334,15 @@ public:
|
||||||
|
|
||||||
void on_insert(const BufferIterator& begin, const BufferIterator& end)
|
void on_insert(const BufferIterator& begin, const BufferIterator& end)
|
||||||
{
|
{
|
||||||
|
assert(begin.is_valid());
|
||||||
|
assert(end.is_valid());
|
||||||
m_first = begin;
|
m_first = begin;
|
||||||
m_last = utf8::previous(end);
|
m_last = utf8::previous(end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_erase(const BufferIterator& begin, const BufferIterator& end)
|
void on_erase(const BufferIterator& begin, const BufferIterator& end)
|
||||||
{
|
{
|
||||||
|
assert(begin.is_valid());
|
||||||
m_first = begin;
|
m_first = begin;
|
||||||
if (m_first >= m_buffer.end())
|
if (m_first >= m_buffer.end())
|
||||||
m_first = utf8::previous(m_buffer.end());
|
m_first = utf8::previous(m_buffer.end());
|
||||||
|
|
|
@ -26,8 +26,10 @@ BufferIterator Range::end() const
|
||||||
|
|
||||||
void Range::check_invariant() const
|
void Range::check_invariant() const
|
||||||
{
|
{
|
||||||
assert(utf8::is_character_start(first()));
|
assert(m_first.is_valid());
|
||||||
assert(utf8::is_character_start(last()));
|
assert(m_last.is_valid());
|
||||||
|
assert(utf8::is_character_start(m_first));
|
||||||
|
assert(utf8::is_character_start(m_last));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void avoid_eol(BufferIterator& it)
|
static void avoid_eol(BufferIterator& it)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user