diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2020-05-13 10:11:02 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2020-05-13 10:11:02 +0200 |
| commit | 98e95af73734bc2a0eaa82bb97fdb2092af1e93c (patch) | |
| tree | 5795767a012ae83461b51c53b58feccd53525758 /core/text-test.c | |
| parent | 8377bdf19649048249b4684c48b6ab98bd3f2766 (diff) | |
| download | vis-98e95af73734bc2a0eaa82bb97fdb2092af1e93c.tar.gz vis-98e95af73734bc2a0eaa82bb97fdb2092af1e93c.tar.xz | |
test/core: add basic save/load tests involving links
Diffstat (limited to 'core/text-test.c')
| -rw-r--r-- | core/text-test.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/core/text-test.c b/core/text-test.c index 3ea28cd..da64a6f 100644 --- a/core/text-test.c +++ b/core/text-test.c @@ -96,6 +96,7 @@ int main(int argc, char *argv[]) { skip_if(TIS_INTERPRETER, 2, "I/O related") { const char *filename = "data"; + unlink(filename); enum TextLoadMethod load_method[] = { TEXT_LOAD_AUTO, @@ -142,6 +143,27 @@ int main(int argc, char *argv[]) { ok(txt && compare(txt, buf), "Verify save (method %zu)", i); text_free(txt); } + + int (*creation[])(const char*, const char*) = { symlink, link }; + const char *names[] = { "symlink", "hardlink" }; + + for (size_t i = 0; i < LENGTH(names); i++) { + const char *linkname = names[i]; + unlink(linkname); + ok(creation[i](filename, linkname) == 0, "%s creation", names[i]); + + snprintf(buf, sizeof buf, "%s\n", names[i]); + txt = text_load(NULL); + ok(txt && insert(txt, 0, buf) && compare(txt, buf), "Preparing %s content", names[i]); + ok(txt && text_save(txt, linkname), "Text save %s", names[i]); + text_free(txt); + + txt = text_load(linkname); + ok(txt && compare(txt, buf), "Load %s", names[i]); + + ok(txt && !text_save_method(txt, linkname, TEXT_SAVE_ATOMIC), "Text save %s atomic", names[i]); + text_free(txt); + } } txt = text_load(NULL); |
