diff options
author | Colin Cross <ccross@android.com> | 2017-02-23 21:23:05 -0800 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2017-02-27 18:18:31 -0800 |
commit | 58021d15c94eb6a81d2673634956b5374af6a1e5 (patch) | |
tree | 8c0b0a97ac977600f45e75fc1d6664594e30b56c /base/file_test.cpp | |
parent | 0cde0eae09e1a3751bb0d921e289ba5cdc228965 (diff) |
Move adb_dirname and adb_basename to libbase
adb already provides an implementation of dirname and basename that
take and produce std::strings, move it into libbase so it can be
used in the implementation of GetExecutableDirectory.
Test: out/host/linux-x86/nativetest64/adb_test/adb_test
Test: out/host/linux-x86/nativetest64/libbase_test/libbase_test
Test: adb shell /data/nativetest64/libbase_test/libbase_test64
Change-Id: Ideb1627607b14562121316d4ed27fa6fb0930684
Diffstat (limited to 'base/file_test.cpp')
-rw-r--r-- | base/file_test.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/base/file_test.cpp b/base/file_test.cpp index ed39ce973..bbd503783 100644 --- a/base/file_test.cpp +++ b/base/file_test.cpp @@ -162,3 +162,15 @@ TEST(file, Readlink) { TEST(file, GetExecutablePath) { ASSERT_NE("", android::base::GetExecutablePath()); } + +TEST(file, Basename) { + EXPECT_EQ("sh", android::base::Basename("/system/bin/sh")); + EXPECT_EQ("sh", android::base::Basename("sh")); + EXPECT_EQ("sh", android::base::Basename("/system/bin/sh/")); +} + +TEST(file, Dirname) { + EXPECT_EQ("/system/bin", android::base::Dirname("/system/bin/sh")); + EXPECT_EQ(".", android::base::Dirname("sh")); + EXPECT_EQ("/system/bin", android::base::Dirname("/system/bin/sh/")); +} |