Skip to content

Commit

Permalink
add test for to_native_path
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelarguedas committed Sep 20, 2018
1 parent 19e1373 commit 7946f66
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/test_filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,35 @@ TEST_F(TestFilesystemFixture, join_path) {
EXPECT_STREQ(ref_str, path);
}

TEST_F(TestFilesystemFixture, to_native_path) {
{
char * path = rcutils_to_native_path("/foo/bar/baz", g_allocator);
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
g_allocator.deallocate(path, g_allocator.state);
});
#ifdef _WIN32
const char * ref_str = "\\foo\\bar\\baz";
#else
const char * ref_str = "/foo/bar/baz";
#endif // _WIN32
ASSERT_FALSE(nullptr == path);
EXPECT_STREQ(ref_str, path);
}
{
char * path = rcutils_to_native_path("/foo//bar/baz", g_allocator);
OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT({
g_allocator.deallocate(path, g_allocator.state);
});
#ifdef _WIN32
const char * ref_str = "\\foo\\\\bar\\baz";
#else
const char * ref_str = "/foo//bar/baz";
#endif // _WIN32
ASSERT_FALSE(nullptr == path);
EXPECT_STREQ(ref_str, path);
}
}

TEST_F(TestFilesystemFixture, exists) {
{
char * path = rcutils_join_path(this->test_path, "dummy_readable_file.txt", g_allocator);
Expand Down

0 comments on commit 7946f66

Please sign in to comment.