diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2023-03-28 05:37:43 +0200 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2023-03-28 05:37:43 +0200 |
commit | 3eed4aad889609bb46fcf55284e3af0129e31578 (patch) | |
tree | 05b3fdf5aa7a66479863ddd2591cf68ca2bc627f /source/test/unittests | |
parent | 7cccceaf6b15981a3f441f55097dac5fa5395ccc (diff) | |
download | kit-3eed4aad889609bb46fcf55284e3af0129e31578.zip |
[test] cache folder
Diffstat (limited to 'source/test/unittests')
-rw-r--r-- | source/test/unittests/file.test.c | 31 |
1 files changed, 31 insertions, 0 deletions
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 <stdio.h> + +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"); |