diff options
author | Stef Walter <stef@thewalter.net> | 2013-06-14 12:49:34 +0200 |
---|---|---|
committer | Stef Walter <stef@thewalter.net> | 2013-06-14 12:49:34 +0200 |
commit | 8c6dd48789bdaf2a3dc800df7ed3416ddc3b7e1f (patch) | |
tree | f9ca355f38bd32fdfedc9faa371b7ddfe3a87835 /common/tests | |
parent | 9e03e9950d78b58a91454b494513d1fc0872dcf2 (diff) |
path: Fix expanding of paths and tests
Diffstat (limited to 'common/tests')
-rw-r--r-- | common/tests/test-path.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/common/tests/test-path.c b/common/tests/test-path.c index 54d6f29..f1bccbd 100644 --- a/common/tests/test-path.c +++ b/common/tests/test-path.c @@ -75,33 +75,33 @@ test_base (void) } } -#define check_equals_and_free(tc, ex, ac) \ +#define check_equals_and_free(ex, ac) \ do { assert_str_eq (ex, ac); free (ac); } while (0) static void test_build (void) { #ifdef OS_UNIX - check_equals_and_free (tc, "/root/second", + check_equals_and_free ("/root/second", p11_path_build ("/root", "second", NULL)); - check_equals_and_free (tc, "/root/second", + check_equals_and_free ("/root/second", p11_path_build ("/root", "/second", NULL)); - check_equals_and_free (tc, "/root/second", + check_equals_and_free ("/root/second", p11_path_build ("/root/", "second", NULL)); - check_equals_and_free (tc, "/root/second/third", + check_equals_and_free ("/root/second/third", p11_path_build ("/root", "second", "third", NULL)); - check_equals_and_free (tc, "/root/second/third", + check_equals_and_free ("/root/second/third", p11_path_build ("/root", "/second/third", NULL)); #else /* OS_WIN32 */ - check_equals_and_free (tc, "C:\\root\\second", + check_equals_and_free ("C:\\root\\second", p11_path_build ("C:\\root", "second", NULL)); - check_equals_and_free (tc, "C:\\root\\second", + check_equals_and_free ("C:\\root\\second", p11_path_build ("C:\\root", "\\second", NULL)); - check_equals_and_free (tc, "C:\\root\\second", + check_equals_and_free ("C:\\root\\second", p11_path_build ("C:\\root\\", "second", NULL)); - check_equals_and_free (tc, "C:\\root\\second\\third", + check_equals_and_free ("C:\\root\\second\\third", p11_path_build ("C:\\root", "second", "third", NULL)); - check_equals_and_free (tc, "C:\\root\\second/third", + check_equals_and_free ("C:\\root\\second/third", p11_path_build ("C:\\root", "second/third", NULL)); #endif } @@ -113,28 +113,34 @@ test_expand (void) #ifdef OS_UNIX putenv ("HOME=/home/blah"); - check_equals_and_free (tc, "/home/blah/my/path", + check_equals_and_free ("/home/blah/my/path", p11_path_expand ("$HOME/my/path")); - check_equals_and_free (tc, "/home/blah/my/path", + check_equals_and_free ("/home/blah/my/path", p11_path_expand ("~/my/path")); + check_equals_and_free ("/home/blah", + p11_path_expand ("$HOME")); + check_equals_and_free ("/home/blah", + p11_path_expand ("~")); putenv ("TEMP=/tmpdir"); - check_equals_and_free (tc, "/tmpdir/my/path", + check_equals_and_free ("/tmpdir/my/path", p11_path_expand ("$TEMP/my/path")); + check_equals_and_free ("/tmpdir", + p11_path_expand ("$TEMP")); #else /* OS_WIN32 */ putenv ("HOME=C:\\Users\\blah"); - check_equals_and_free (tc, "C:\\Users\\blah\\path", + check_equals_and_free ("C:\\Users\\blah\\path", p11_path_expand ("$HOME/path")); - check_equals_and_free (tc, "C:\\Users\\blah\\path", + check_equals_and_free ("C:\\Users\\blah\\path", p11_path_expand ("$HOME\\path")); - check_equals_and_free (tc, "C:\\Users\\blah\\path", + check_equals_and_free ("C:\\Users\\blah\\path", p11_path_expand ("~/path")); - check_equals_and_free (tc, "C:\\Users\\blah\\path", + check_equals_and_free ("C:\\Users\\blah\\path", p11_path_expand ("~\\path")); putenv ("TEMP=C:\\Temp Directory"); - check_equals_and_free (tc, "C:\\Temp Directory\\path", + check_equals_and_free ("C:\\Temp Directory\\path", p11_path_expand ("$TEMP/path")); - check_equals_and_free (tc, "C:\\Temp Directory\\path", + check_equals_and_free ("C:\\Temp Directory\\path", p11_path_expand ("$TEMP\\path")); #endif |