From 3eed4aad889609bb46fcf55284e3af0129e31578 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Tue, 28 Mar 2023 05:37:43 +0200 Subject: [test] cache folder --- source/test/unittests/file.test.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'source/test/unittests/file.test.c') diff --git a/source/test/unittests/file.test.c b/source/test/unittests/file.test.c index 3b6d6d0..2207269 100644 --- a/source/test/unittests/file.test.c +++ b/source/test/unittests/file.test.c @@ -11,6 +11,37 @@ # define S_DELIM_ "/" #endif +#include + +TEST("file path cache") { + kit_allocator_t alloc = kit_alloc_default(); + + string_t user = path_user(alloc); + string_t cache = path_cache(alloc); + + DA_RESIZE(cache, cache.size + 1); + cache.values[cache.size - 1] = '\0'; + DA_RESIZE(cache, cache.size - 1); + printf("\nCache folder: %s\n", cache.values); + + string_t expected = +#if defined(_WIN32) && !defined(__CYGWIN__) + path_join(WRAP_STR(user), SZ("AppData" PATH_DELIM "Local"), + alloc); +#elif defined(__APPLE__) + path_join(WRAP_STR(user), SZ("Library" PATH_DELIM "Caches"), + alloc); +#else + path_join(WRAP_STR(user), SZ(".cache"), alloc); +#endif + + REQUIRE(AR_EQUAL(cache, expected)); + + DA_DESTROY(user); + DA_DESTROY(cache); + DA_DESTROY(expected); +} + TEST("file path normalize one") { str_t foo = SZ("foo/bar/../baz"); str_t foo_norm = SZ("foo" S_DELIM_ "baz"); -- cgit v1.2.3