Three test cases are failing on my line() method implemented here https://github.com/Ttibsi/gapvector/blob/gv2/gapbuffer.h#L398-L419 -- going through it with gdb and it looks like the calculation of the line_end part is wrong, but I'm not sure what I'm missing. If I breakpoint at the assert statement and do line_end - line_start, it looks like the iterators are pointing to the wrong plac e-- I'm getting values much larger than even the current size of the container at the time.
(gdb) p line_end - line_start
$2 = 22
(gdb) p size()
$3 = 14
(gdb) p capacity()
$4 = 22
I'm pretty sure this is something to do with the actual gap being taken into consideration in the iterator -- see line 62-63 for an example. I think I do want that to be taken into consideration, so I can just use the values in the container for stdlib algorithms and things like that.
Alternatively, I could add something to the line() method to take that into consideration, but I'm not sure exactly what. I've tried a few things -- else if (line_end == gapEnd) { line_end = gapStart; } and else if (line_end == end()) { line_end -= gap_size(); } are both alternate else blocks I've tried adding to the if statement on lines 414-416, and the latter just segfaults on the string constructor and the former requires extra work to turn a pointer into an iterator and I'm not convinced it's the right approach. Can anyone else see something I'm missing here?