aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/cpp
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2018-06-20 07:56:11 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-20 07:57:33 -0700
commit4e578e6f7205a352630720ed482967b6edb4afca (patch)
tree72183211005d58534693656832922c63a5f55f15 /src/test/cpp
parent3e1e177502133f906d1614e32f2c4af02167e990 (diff)
Make blaze_util::AsAbsoluteWindowsPath support wstring as input
Now we have: bool AsAbsoluteWindowsPath(const std::wstring& path, std::wstring* result, std::string* error); This change helps making the C++ native launcher work with UTF-16. See https://github.com/bazelbuild/bazel/issues/4473 Closes #5406. Change-Id: I7eaf55f9fe5a4d41e3dd09edc2a21e9b3cc9277c PiperOrigin-RevId: 201352866
Diffstat (limited to 'src/test/cpp')
-rw-r--r--src/test/cpp/util/path_windows_test.cc26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/test/cpp/util/path_windows_test.cc b/src/test/cpp/util/path_windows_test.cc
index c78c4ab012..bcf62622d5 100644
--- a/src/test/cpp/util/path_windows_test.cc
+++ b/src/test/cpp/util/path_windows_test.cc
@@ -41,9 +41,6 @@ using std::string;
using std::unique_ptr;
using std::wstring;
-// Methods defined in path_windows.cc that are only visible for testing.
-string NormalizeWindowsPath(string path);
-
TEST(PathWindowsTest, TestNormalizeWindowsPath) {
ASSERT_EQ(string(""), NormalizeWindowsPath(""));
ASSERT_EQ(string(""), NormalizeWindowsPath("."));
@@ -56,6 +53,19 @@ TEST(PathWindowsTest, TestNormalizeWindowsPath) {
ASSERT_EQ(string("c:\\"), NormalizeWindowsPath("c:/"));
ASSERT_EQ(string("c:\\"), NormalizeWindowsPath("c:\\"));
ASSERT_EQ(string("c:\\foo\\bar"), NormalizeWindowsPath("c:\\..//foo/./bar/"));
+
+ ASSERT_EQ(wstring(L""), NormalizeWindowsPath(L""));
+ ASSERT_EQ(wstring(L""), NormalizeWindowsPath(L"."));
+ ASSERT_EQ(wstring(L"foo"), NormalizeWindowsPath(L"foo"));
+ ASSERT_EQ(wstring(L"foo"), NormalizeWindowsPath(L"foo/"));
+ ASSERT_EQ(wstring(L"foo\\bar"), NormalizeWindowsPath(L"foo//bar"));
+ ASSERT_EQ(wstring(L"foo\\bar"), NormalizeWindowsPath(L"../..//foo/./bar"));
+ ASSERT_EQ(wstring(L"foo\\bar"), NormalizeWindowsPath(L"../foo/baz/../bar"));
+ ASSERT_EQ(wstring(L"c:\\"), NormalizeWindowsPath(L"c:"));
+ ASSERT_EQ(wstring(L"c:\\"), NormalizeWindowsPath(L"c:/"));
+ ASSERT_EQ(wstring(L"c:\\"), NormalizeWindowsPath(L"c:\\"));
+ ASSERT_EQ(wstring(L"c:\\foo\\bar"),
+ NormalizeWindowsPath(L"c:\\..//foo/./bar/"));
}
TEST(PathWindowsTest, TestDirname) {
@@ -201,9 +211,16 @@ TEST(PathWindowsTest, TestAsAbsoluteWindowsPath) {
ASSERT_TRUE(AsAbsoluteWindowsPath("c:/", &actual, nullptr));
ASSERT_EQ(L"\\\\?\\c:\\", actual);
+ ASSERT_TRUE(AsAbsoluteWindowsPath(L"c:/", &actual, nullptr));
+ ASSERT_EQ(L"\\\\?\\c:\\", actual);
+
ASSERT_TRUE(AsAbsoluteWindowsPath("c:/..\\non-existent//", &actual, nullptr));
ASSERT_EQ(L"\\\\?\\c:\\non-existent", actual);
+ ASSERT_TRUE(
+ AsAbsoluteWindowsPath(L"c:/..\\non-existent//", &actual, nullptr));
+ ASSERT_EQ(L"\\\\?\\c:\\non-existent", actual);
+
WCHAR cwd[MAX_PATH];
wstring cwdw(CstringToWstring(GetCwd().c_str()).get());
wstring expected =
@@ -211,6 +228,9 @@ TEST(PathWindowsTest, TestAsAbsoluteWindowsPath) {
((cwdw.back() == L'\\') ? L"non-existent" : L"\\non-existent");
ASSERT_TRUE(AsAbsoluteWindowsPath("non-existent", &actual, nullptr));
ASSERT_EQ(actual, expected);
+
+ ASSERT_TRUE(AsAbsoluteWindowsPath(L"non-existent", &actual, nullptr));
+ ASSERT_EQ(actual, expected);
}
TEST(PathWindowsTest, TestAsShortWindowsPath) {