add SelectionList::check_invariant

This commit is contained in:
Maxime Coste 2013-05-03 13:38:48 +02:00
parent 9b3e0c8055
commit 4c4b6a404d
3 changed files with 19 additions and 5 deletions

View File

@ -21,12 +21,11 @@ DynamicSelectionList& DynamicSelectionList::operator=(SelectionList selections)
void DynamicSelectionList::check_invariant() const
{
#ifdef KAK_DEBUG
if (empty())
return;
const Buffer* buf = &buffer();
for (auto& sel : *this)
{
kak_assert(buf == &sel.buffer());
sel.check_invariant();
}
kak_assert(&front().buffer() == buf);
SelectionList::check_invariant();
#endif
}

View File

@ -142,4 +142,17 @@ void SelectionList::update_erase(const BufferCoord& begin, const BufferCoord& en
on_buffer_change<UpdateErase>(*this, begin, end, end.line);
}
void SelectionList::check_invariant() const
{
#ifdef KAK_DEBUG
for (size_t i = 0; i < size(); ++i)
{
auto& sel = (*this)[i];
sel.check_invariant();
if (i+1 < size())
kak_assert(sel.begin() <= (*this)[i+1].begin());
}
#endif
}
}

View File

@ -74,6 +74,8 @@ struct SelectionList : std::vector<Selection>
void update_insert(const BufferCoord& begin, const BufferCoord& end);
void update_erase(const BufferCoord& begin, const BufferCoord& end);
void check_invariant() const;
};
}