Skip to content

Commit

Permalink
4 ➡️ 5
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <[email protected]>
  • Loading branch information
chapulina committed Mar 3, 2022
2 parents ce7cb4a + ad0fc88 commit e6fe261
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,12 @@ jobs:
uses: ignition-tooling/action-ignition-ci@focal
with:
codecov-enabled: true
jammy-ci:
runs-on: ubuntu-latest
name: Ubuntu Jammy CI
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Compile and test
id: ci
uses: ignition-tooling/action-ignition-ci@jammy
2 changes: 1 addition & 1 deletion include/ignition/common/Filesystem.hh
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ namespace ignition
/// files, by appending numbers to it (i.e. (0), (1), ...)
/// \param[in] _pathAndName Full absolute path and file name up to the
/// file extension.
/// \param[in] _extension File extension, such as "ddf".
/// \param[in] _extension File extension, such as "sdf".
/// \return Full path with name and extension, which doesn't collide with
/// existing files
std::string IGNITION_COMMON_VISIBLE uniqueFilePath(
Expand Down
35 changes: 34 additions & 1 deletion src/Filesystem_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -413,38 +413,71 @@ TEST_F(FilesystemTest, IGN_UTILS_TEST_DISABLED_ON_WIN32(cwd_error))
}

/////////////////////////////////////////////////
TEST_F(FilesystemTest, basename)
TEST_F(FilesystemTest, decomposition)
{
std::string absolute = joinPaths("", "home", "bob", "foo");
EXPECT_EQ(basename(absolute), "foo");
#ifndef _WIN32
EXPECT_EQ(parentPath(absolute), "/home/bob");
#else
EXPECT_EQ(parentPath(absolute), "home\\bob");
#endif

std::string relative = joinPaths("baz", "foobar");
EXPECT_EQ(basename(relative), "foobar");
EXPECT_EQ(parentPath(relative), "baz");

std::string bname = "bzzz";
EXPECT_EQ(basename(bname), "bzzz");
EXPECT_EQ(parentPath(bname), "bzzz");

std::string nobase = joinPaths("baz", "");
EXPECT_EQ(basename(nobase), "baz");
#ifndef _WIN32
EXPECT_EQ(parentPath(nobase), "baz/");
#else
EXPECT_EQ(parentPath(nobase), "baz");
#endif

std::string multiple_slash = separator("baz") + separator("") + separator("")
+ separator("");
EXPECT_EQ(basename(multiple_slash), "baz");
#ifndef _WIN32
EXPECT_EQ(parentPath(multiple_slash), "baz//");
#else
EXPECT_EQ(parentPath(multiple_slash), "baz\\\\");
#endif

std::string multiple_slash_middle = separator("") + separator("home")
+ separator("") + separator("") + separator("bob") + separator("foo");
EXPECT_EQ(basename(multiple_slash_middle), "foo");
#ifndef _WIN32
EXPECT_EQ(parentPath(multiple_slash_middle), "/home///bob");
#else
EXPECT_EQ(parentPath(multiple_slash_middle), "\\home\\\\\\bob");
#endif

std::string multiple_slash_start = separator("") + separator("")
+ separator("") + separator("home") + separator("bob") + separator("foo");
EXPECT_EQ(basename(multiple_slash_start), "foo");
#ifndef _WIN32
EXPECT_EQ(parentPath(multiple_slash_start), "///home/bob");
#else
EXPECT_EQ(parentPath(multiple_slash_start), "\\\\\\home\\bob");
#endif

std::string slash_only = separator("") + separator("");
EXPECT_EQ(basename(slash_only), separator(""));
EXPECT_EQ(parentPath(slash_only), "");

std::string multiple_slash_only = separator("") + separator("")
+ separator("") + separator("");
EXPECT_EQ(basename(multiple_slash_only), separator(""));
#ifndef _WIN32
EXPECT_EQ(parentPath(multiple_slash_only), "//");
#else
EXPECT_EQ(parentPath(multiple_slash_only), "\\\\");
#endif
}

/////////////////////////////////////////////////
Expand Down

0 comments on commit e6fe261

Please sign in to comment.