diff options
author | Esteban Manchado Velázquez <emanchado@demiurgo.org> | 2012-02-20 22:53:25 +0100 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-03-08 21:16:46 -0500 |
commit | 998891e7342155f7c0c5839f4c5816ace686134f (patch) | |
tree | af17e678885f4938c92530a6c46eac195d977f62 /src/test | |
parent | dbd170f752b422004835def53f84b786f32c9a08 (diff) | |
download | tor-998891e7342155f7c0c5839f4c5816ace686134f.tar.gz tor-998891e7342155f7c0c5839f4c5816ace686134f.zip |
Add unit tests for path_is_relative
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_util.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index e2050f8d77..741b8d5395 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -1503,6 +1503,42 @@ test_util_sscanf(void) ; } +static void +test_util_path_is_relative(void) +{ + /* OS-independent tests */ + test_eq(1, path_is_relative("")); + test_eq(1, path_is_relative("dir")); + test_eq(1, path_is_relative("dir/")); + test_eq(1, path_is_relative("./dir")); + test_eq(1, path_is_relative("../dir")); + + test_eq(0, path_is_relative("/")); + test_eq(0, path_is_relative("/dir")); + test_eq(0, path_is_relative("/dir/")); + + /* Windows */ +#ifdef MS_WINDOWS + /* I don't have Windows so I can't test this, hence the "#ifdef + 0". These are tests that look useful, so please try to get them + running and uncomment if it all works as it should */ +#ifdef 0 + test_eq(1, path_is_relative("dir")); + test_eq(1, path_is_relative("dir\\")); + test_eq(1, path_is_relative("dir\\a:")); + test_eq(1, path_is_relative("dir\\a:\\")); + + test_eq(0, path_is_relative("\\dir")); + test_eq(0, path_is_relative("a:\\dir")); + test_eq(0, path_is_relative("z:\\dir")); + test_eq(0, path_is_relative("http:\\dir")); +#endif +#endif + + done: + ; +} + /** Run unittests for memory pool allocator */ static void test_util_mempool(void) @@ -2855,6 +2891,7 @@ struct testcase_t util_tests[] = { UTIL_LEGACY(mmap), UTIL_LEGACY(threads), UTIL_LEGACY(sscanf), + UTIL_LEGACY(path_is_relative), UTIL_LEGACY(strtok), UTIL_LEGACY(di_ops), UTIL_TEST(find_str_at_start_of_line, 0), |