From a12ea095fa0651015cbc31e094f331a4754da379 Mon Sep 17 00:00:00 2001 From: William Woodall Date: Mon, 21 May 2018 21:16:13 -0700 Subject: [PATCH] fixup --- CMakeLists.txt | 8 ----- test/test_filesystem.cpp | 68 +++++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 41 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0493be3c..c04577fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,6 @@ endif() set(rcutils_sources src/allocator.c src/cmdline_parser.c - src/concat.c src/error_handling.c src/filesystem.c src/find.c @@ -207,13 +206,6 @@ if(BUILD_TESTING) target_link_libraries(test_find ${PROJECT_NAME}) endif() - rcutils_custom_add_gtest(test_concat - test/test_concat.cpp - ) - if(TARGET test_concat) - target_link_libraries(test_concat ${PROJECT_NAME}) - endif() - rcutils_custom_add_gtest(test_string_array test/test_string_array.cpp ) diff --git a/test/test_filesystem.cpp b/test/test_filesystem.cpp index 988b6470..9a6c2de9 100644 --- a/test/test_filesystem.cpp +++ b/test/test_filesystem.cpp @@ -19,8 +19,10 @@ static char cwd[1024]; +static rcutils_allocator_t g_allocator = rcutils_get_default_allocator(); + TEST(test_filesystem, join_path) { - char * path = rcutils_join_path("foo", "bar"); + char * path = rcutils_join_path("foo", "bar", g_allocator); #ifdef _WIN32 const char * ref_str = "foo\\bar"; #else @@ -33,47 +35,47 @@ TEST(test_filesystem, join_path) { TEST(test_filesystem, exists) { EXPECT_FALSE(rcutils_get_cwd(NULL, 1024)); EXPECT_TRUE(rcutils_get_cwd(cwd, 1024)); - char * path = rcutils_join_path(cwd, "test"); - path = rcutils_join_path(path, "dummy_readable_file.txt"); + char * path = rcutils_join_path(cwd, "test", g_allocator); + path = rcutils_join_path(path, "dummy_readable_file.txt", g_allocator); EXPECT_TRUE(rcutils_exists(path)); - path = rcutils_join_path(cwd, "test"); - path = rcutils_join_path(path, "dummy_folder"); + path = rcutils_join_path(cwd, "test", g_allocator); + path = rcutils_join_path(path, "dummy_folder", g_allocator); EXPECT_TRUE(rcutils_exists(path)); } TEST(test_filesystem, is_directory) { EXPECT_TRUE(rcutils_get_cwd(cwd, 1024)); - char * path = rcutils_join_path(cwd, "test"); - path = rcutils_join_path(path, "dummy_readable_file.txt"); + char * path = rcutils_join_path(cwd, "test", g_allocator); + path = rcutils_join_path(path, "dummy_readable_file.txt", g_allocator); EXPECT_FALSE(rcutils_is_directory(path)); - path = rcutils_join_path(cwd, "test"); - path = rcutils_join_path(path, "dummy_folder"); + path = rcutils_join_path(cwd, "test", g_allocator); + path = rcutils_join_path(path, "dummy_folder", g_allocator); EXPECT_TRUE(rcutils_is_directory(path)); } TEST(test_filesystem, is_file) { EXPECT_TRUE(rcutils_get_cwd(cwd, 1024)); - char * path = rcutils_join_path(cwd, "test"); - path = rcutils_join_path(path, "dummy_readable_file.txt"); + char * path = rcutils_join_path(cwd, "test", g_allocator); + path = rcutils_join_path(path, "dummy_readable_file.txt", g_allocator); EXPECT_TRUE(rcutils_is_file(path)); - path = rcutils_join_path(cwd, "test"); - path = rcutils_join_path(path, "dummy_folder"); + path = rcutils_join_path(cwd, "test", g_allocator); + path = rcutils_join_path(path, "dummy_folder", g_allocator); EXPECT_FALSE(rcutils_is_file(path)); } TEST(test_filesystem, is_readable) { EXPECT_TRUE(rcutils_get_cwd(cwd, 1024)); - char * path = rcutils_join_path(cwd, "test"); - path = rcutils_join_path(path, "dummy_readable_file.txt"); + char * path = rcutils_join_path(cwd, "test", g_allocator); + path = rcutils_join_path(path, "dummy_readable_file.txt", g_allocator); EXPECT_TRUE(rcutils_is_readable(path)); - path = rcutils_join_path(cwd, "test"); - path = rcutils_join_path(path, "dummy_folder"); + path = rcutils_join_path(cwd, "test", g_allocator); + path = rcutils_join_path(path, "dummy_folder", g_allocator); EXPECT_TRUE(rcutils_is_readable(path)); - path = rcutils_join_path(cwd, "test"); - path = rcutils_join_path(path, "dummy_readable_writable_file.txt"); + path = rcutils_join_path(cwd, "test", g_allocator); + path = rcutils_join_path(path, "dummy_readable_writable_file.txt", g_allocator); EXPECT_TRUE(rcutils_is_readable(path)); - path = rcutils_join_path(cwd, "test"); - path = rcutils_join_path(path, "dummy_nonexisting_file.txt"); + path = rcutils_join_path(cwd, "test", g_allocator); + path = rcutils_join_path(path, "dummy_nonexisting_file.txt", g_allocator); EXPECT_FALSE(rcutils_is_readable(path)); } @@ -82,14 +84,14 @@ TEST(test_filesystem, is_writable) { // path = std::string(cwd) + delimiter + std::string("test") + delimiter + std::string( // "dummy_readable_file.txt"); // EXPECT_FALSE(rcutils_is_writable(path.c_str())); - char * path = rcutils_join_path(cwd, "test"); - path = rcutils_join_path(path, "dummy_folder"); + char * path = rcutils_join_path(cwd, "test", g_allocator); + path = rcutils_join_path(path, "dummy_folder", g_allocator); EXPECT_TRUE(rcutils_is_writable(path)); - path = rcutils_join_path(cwd, "test"); - path = rcutils_join_path(path, "dummy_readable_writable_file.txt"); + path = rcutils_join_path(cwd, "test", g_allocator); + path = rcutils_join_path(path, "dummy_readable_writable_file.txt", g_allocator); EXPECT_TRUE(rcutils_is_writable(path)); - path = rcutils_join_path(cwd, "test"); - path = rcutils_join_path(path, "dummy_nonexisting_file.txt"); + path = rcutils_join_path(cwd, "test", g_allocator); + path = rcutils_join_path(path, "dummy_nonexisting_file.txt", g_allocator); EXPECT_FALSE(rcutils_is_writable(path)); } @@ -97,13 +99,13 @@ TEST(test_filesystem, is_readable_and_writable) { EXPECT_TRUE(rcutils_get_cwd(cwd, 1024)); // path = std::string(cwd) + std::string("/test/dummy_readable_file.txt"); // EXPECT_FALSE(rcutils_is_readable_and_writable(path.c_str())); - char * path = rcutils_join_path(cwd, "test"); - path = rcutils_join_path(path, "dummy_folder"); + char * path = rcutils_join_path(cwd, "test", g_allocator); + path = rcutils_join_path(path, "dummy_folder", g_allocator); EXPECT_TRUE(rcutils_is_readable_and_writable(path)); - path = rcutils_join_path(cwd, "test"); - path = rcutils_join_path(path, "dummy_readable_writable_file.txt"); + path = rcutils_join_path(cwd, "test", g_allocator); + path = rcutils_join_path(path, "dummy_readable_writable_file.txt", g_allocator); EXPECT_TRUE(rcutils_is_readable_and_writable(path)); - path = rcutils_join_path(cwd, "test"); - path = rcutils_join_path(path, "dummy_nonexisting_file.txt"); + path = rcutils_join_path(cwd, "test", g_allocator); + path = rcutils_join_path(path, "dummy_nonexisting_file.txt", g_allocator); EXPECT_FALSE(rcutils_is_readable_and_writable(path)); }