diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-12-16 21:53:43 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-12-16 22:20:05 +0100 |
| commit | 1adb6b47dccd992f3cb8938139c8f05b51db70b1 (patch) | |
| tree | 0341971c483ba135ee2d798b8612c6f778b201b5 | |
| parent | 138d455393683532fb9d96fd398dfcdfa5d97057 (diff) | |
| download | vis-1adb6b47dccd992f3cb8938139c8f05b51db70b1.tar.gz vis-1adb6b47dccd992f3cb8938139c8f05b51db70b1.tar.xz | |
text/core: add some mark related tests
| -rw-r--r-- | core/text.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/core/text.c b/core/text.c index 8028599..7154b70 100644 --- a/core/text.c +++ b/core/text.c @@ -108,5 +108,30 @@ int main(int argc, char *argv[]) { text_undo(txt); ok(text_delete(txt, 5, 5) && compare(txt, "12345"), "Deleting at end"); + ok(text_mark_get(txt, text_mark_set(txt, -1)) == EPOS, "Mark invalid 1"); + ok(text_mark_get(txt, text_mark_set(txt, text_size(txt)+1)) == EPOS, "Mark invalid 2"); + Mark bof = text_mark_set(txt, 0); + ok(text_mark_get(txt, bof) == 0, "Mark at beginning of file"); + size_t pos = 3; + Mark mof = text_mark_set(txt, pos); + ok(text_mark_get(txt, mof) == pos, "Mark in the middle"); + Mark eof = text_mark_set(txt, text_size(txt)); + ok(text_mark_get(txt, eof) == text_size(txt), "Mark at end of file"); + const char *chunk = "new content"; + size_t newpos = pos+strlen(chunk); + ok(insert(txt, pos-1, chunk), "Insert before mark"); + ok(text_mark_get(txt, bof) == 0, "Mark at beginning adjusted 1"); + ok(text_mark_get(txt, mof) == newpos, "Mark in the middle adjusted 1"); + ok(text_mark_get(txt, eof) == text_size(txt), "Mark at end adjusted 1"); + ok(insert(txt, newpos+1, chunk), "Insert after mark"); + ok(text_mark_get(txt, bof) == 0, "Mark at beginning adjusted 2"); + ok(text_mark_get(txt, mof) == newpos, "Mark in the middle adjusted 2"); + ok(text_mark_get(txt, eof) == text_size(txt), "Mark at end adjusted 2"); + text_snapshot(txt); + ok(text_delete(txt, newpos, 1), "Deleting mark"); + ok(text_mark_get(txt, mof) == EPOS, "Mark in the middle deleted"); + text_undo(txt); + ok(text_mark_get(txt, mof) == newpos, "Mark restored"); + return exit_status(); } |
