aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTobias Pflug <tobias.pflug@gmail.com>2020-05-08 15:07:40 +0200
committerTobias Pflug <tobias.pflug@gmail.com>2020-05-08 15:07:40 +0200
commit2191141274cfefcb9ffbafbbfcdc58414fb28f1a (patch)
tree365f3478eea6ec860a9e66220b97dedfe1eb9e3e /src
parente3df9c2a6e867d0e038cb26af40501511607e007 (diff)
Enable `baseNameOf` test
Add note about removal of trailing slashes in the doc comment of baseNameOf and enabled the test.
Diffstat (limited to 'src')
-rw-r--r--src/libutil/tests/tests.cc6
-rw-r--r--src/libutil/util.hh2
2 files changed, 3 insertions, 5 deletions
diff --git a/src/libutil/tests/tests.cc b/src/libutil/tests/tests.cc
index 1b016430d..d46f6a5a4 100644
--- a/src/libutil/tests/tests.cc
+++ b/src/libutil/tests/tests.cc
@@ -127,11 +127,9 @@ namespace nix {
ASSERT_EQ(p1, "");
}
- // XXX: according to the doc of `baseNameOf`, baseNameOf("/dir/") should return
- // "" but it actually returns "dir"
- TEST(baseNameOf, DISABLED_trailingSlash) {
+ TEST(baseNameOf, trailingSlash) {
auto p1 = baseNameOf("/dir/");
- ASSERT_EQ(p1, "");
+ ASSERT_EQ(p1, "dir");
}
/* ----------------------------------------------------------------------------
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 38a0f7a5c..a63ee05b3 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -63,7 +63,7 @@ Path canonPath(const Path & path, bool resolveSymlinks = false);
Path dirOf(const Path & path);
/* Return the base name of the given canonical path, i.e., everything
- following the final `/'. */
+ following the final `/' (trailing slashes are removed). */
std::string_view baseNameOf(std::string_view path);
/* Check whether 'path' is a descendant of 'dir'. */