summaryrefslogtreecommitdiffstats
path: root/test/test_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_util.c')
-rw-r--r--test/test_util.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/test/test_util.c b/test/test_util.c
index 8c8f36a..c140e34 100644
--- a/test/test_util.c
+++ b/test/test_util.c
@@ -1,5 +1,5 @@
/*
- Copyright 2007-2020 David Robillard <d@drobilla.net>
+ Copyright 2007-2022 David Robillard <d@drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -14,44 +14,30 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#define _XOPEN_SOURCE 600 /* for mkstemp */
-
#undef NDEBUG
-#ifdef _WIN32
-# include "lilv_internal.h"
-#endif
-
#include "../src/filesystem.h"
-#ifdef _WIN32
-# include <io.h>
-# define mkstemp(pat) _mktemp(pat)
-#endif
+#include "lilv/lilv.h"
#include <assert.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
int
main(void)
{
assert(!lilv_path_canonical(NULL));
- char a_path[16];
- char b_path[16];
- strncpy(a_path, "copy_a_XXXXXX", sizeof(a_path));
- strncpy(b_path, "copy_b_XXXXXX", sizeof(b_path));
- mkstemp(a_path);
- mkstemp(b_path);
+ char* const dir = lilv_create_temporary_directory("lilv_test_util_XXXXXX");
+ char* const a_path = lilv_path_join(dir, "copy_a_XXXXXX");
+ char* const b_path = lilv_path_join(dir, "copy_b_XXXXXX");
- FILE* fa = fopen(a_path, "w");
- FILE* fb = fopen(b_path, "w");
+ FILE* const fa = fopen(a_path, "w");
+ FILE* const fb = fopen(b_path, "w");
fprintf(fa, "AA\n");
fprintf(fb, "AB\n");
- fclose(fa);
fclose(fb);
+ fclose(fa);
assert(lilv_copy_file("does/not/exist", "copy"));
assert(lilv_copy_file(a_path, "not/a/dir/copy"));
@@ -63,5 +49,12 @@ main(void)
assert(!lilv_file_equals(a_path, "does/not/exist"));
assert(!lilv_file_equals("does/not/exist", "/does/not/either"));
+ assert(!lilv_remove(a_path));
+ assert(!lilv_remove(b_path));
+ assert(!lilv_remove(dir));
+
+ lilv_free(b_path);
+ lilv_free(a_path);
+ lilv_free(dir);
return 0;
}