@@ -173,9 +173,9 @@ TEST(Platforms_FileSystem, SimplifyPath)
173173 EXPECT_STREQ (FileSystem::SimplifyPath (" \\ " , ' \\ ' ).c_str (), " " );
174174
175175 EXPECT_STREQ (FileSystem::SimplifyPath (" //" , ' /' ).c_str (), " /" );
176- EXPECT_STREQ (FileSystem::SimplifyPath (" //" , ' \\ ' ).c_str (), " " );
176+ EXPECT_STREQ (FileSystem::SimplifyPath (" //" , ' \\ ' ).c_str (), " \\\\ " ); // UNC path
177177 EXPECT_STREQ (FileSystem::SimplifyPath (" \\\\ " , ' /' ).c_str (), " /" );
178- EXPECT_STREQ (FileSystem::SimplifyPath (" \\\\ " , ' \\ ' ).c_str (), " " );
178+ EXPECT_STREQ (FileSystem::SimplifyPath (" \\\\ " , ' \\ ' ).c_str (), " \\\\ " ); // UNC path
179179
180180 EXPECT_STREQ (FileSystem::SimplifyPath (" a/" , ' /' ).c_str (), " a" );
181181 EXPECT_STREQ (FileSystem::SimplifyPath (" a/" , ' \\ ' ).c_str (), " a" );
@@ -188,15 +188,20 @@ TEST(Platforms_FileSystem, SimplifyPath)
188188 EXPECT_STREQ (FileSystem::SimplifyPath (" \\ a" , ' \\ ' ).c_str (), " a" );
189189
190190 EXPECT_STREQ (FileSystem::SimplifyPath (" //a" , ' /' ).c_str (), " /a" );
191- EXPECT_STREQ (FileSystem::SimplifyPath (" //a" , ' \\ ' ).c_str (), " a" );
191+ EXPECT_STREQ (FileSystem::SimplifyPath (" //a" , ' \\ ' ).c_str (), " \\\\ a" ); // UNC path
192192 EXPECT_STREQ (FileSystem::SimplifyPath (" \\\\ a" , ' /' ).c_str (), " /a" );
193- EXPECT_STREQ (FileSystem::SimplifyPath (" \\\\ a" , ' \\ ' ).c_str (), " a" );
193+ EXPECT_STREQ (FileSystem::SimplifyPath (" \\\\ a" , ' \\ ' ).c_str (), " \\\\ a" ); // UNC path
194194
195195 EXPECT_STREQ (FileSystem::SimplifyPath (" /a/" , ' /' ).c_str (), " /a" );
196196 EXPECT_STREQ (FileSystem::SimplifyPath (" /a/" , ' \\ ' ).c_str (), " a" );
197197 EXPECT_STREQ (FileSystem::SimplifyPath (" \\ a/" , ' /' ).c_str (), " /a" );
198198 EXPECT_STREQ (FileSystem::SimplifyPath (" \\ a/" , ' \\ ' ).c_str (), " a" );
199199
200+ EXPECT_STREQ (FileSystem::SimplifyPath (" c:/" , ' /' ).c_str (), " c:" );
201+ EXPECT_STREQ (FileSystem::SimplifyPath (" c:\\ " , ' /' ).c_str (), " c:" );
202+ EXPECT_STREQ (FileSystem::SimplifyPath (" c:/" , ' \\ ' ).c_str (), " c:" );
203+ EXPECT_STREQ (FileSystem::SimplifyPath (" c:\\ " , ' \\ ' ).c_str (), " c:" );
204+
200205 EXPECT_STREQ (FileSystem::SimplifyPath (" a/b" , ' /' ).c_str (), " a/b" );
201206 EXPECT_STREQ (FileSystem::SimplifyPath (" a\\ b" , ' /' ).c_str (), " a/b" );
202207 EXPECT_STREQ (FileSystem::SimplifyPath (" a/b" , ' \\ ' ).c_str (), " a\\ b" );
@@ -211,6 +216,34 @@ TEST(Platforms_FileSystem, SimplifyPath)
211216 EXPECT_STREQ (FileSystem::SimplifyPath (" a/./b" , ' \\ ' ).c_str (), " a\\ b" );
212217 EXPECT_STREQ (FileSystem::SimplifyPath (" a\\ .\\ b" , ' \\ ' ).c_str (), " a\\ b" );
213218
219+ EXPECT_STREQ (FileSystem::SimplifyPath (" a/.//b" , ' /' ).c_str (), " a/b" );
220+ EXPECT_STREQ (FileSystem::SimplifyPath (" a\\ .\\\\ b" , ' /' ).c_str (), " a/b" );
221+ EXPECT_STREQ (FileSystem::SimplifyPath (" a/.//b" , ' \\ ' ).c_str (), " a\\ b" );
222+ EXPECT_STREQ (FileSystem::SimplifyPath (" a\\ .\\\\ b" , ' \\ ' ).c_str (), " a\\ b" );
223+
224+ EXPECT_STREQ (FileSystem::SimplifyPath (" a//./b" , ' /' ).c_str (), " a/b" );
225+ EXPECT_STREQ (FileSystem::SimplifyPath (" a\\\\ .\\ b" , ' /' ).c_str (), " a/b" );
226+ EXPECT_STREQ (FileSystem::SimplifyPath (" a//./b" , ' \\ ' ).c_str (), " a\\ b" );
227+ EXPECT_STREQ (FileSystem::SimplifyPath (" a\\\\ .\\ b" , ' \\ ' ).c_str (), " a\\ b" );
228+
229+ EXPECT_STREQ (FileSystem::SimplifyPath (" ." , ' /' ).c_str (), " " );
230+ EXPECT_STREQ (FileSystem::SimplifyPath (" ." , ' \\ ' ).c_str (), " " );
231+
232+ EXPECT_STREQ (FileSystem::SimplifyPath (" ./" , ' /' ).c_str (), " " );
233+ EXPECT_STREQ (FileSystem::SimplifyPath (" .\\ " , ' /' ).c_str (), " " );
234+ EXPECT_STREQ (FileSystem::SimplifyPath (" ./" , ' \\ ' ).c_str (), " " );
235+ EXPECT_STREQ (FileSystem::SimplifyPath (" .\\ " , ' \\ ' ).c_str (), " " );
236+
237+ EXPECT_STREQ (FileSystem::SimplifyPath (" /." , ' /' ).c_str (), " /" );
238+ EXPECT_STREQ (FileSystem::SimplifyPath (" \\ ." , ' /' ).c_str (), " /" );
239+ EXPECT_STREQ (FileSystem::SimplifyPath (" /." , ' \\ ' ).c_str (), " " );
240+ EXPECT_STREQ (FileSystem::SimplifyPath (" \\ ." , ' \\ ' ).c_str (), " " );
241+
242+ EXPECT_STREQ (FileSystem::SimplifyPath (" /./" , ' /' ).c_str (), " /" );
243+ EXPECT_STREQ (FileSystem::SimplifyPath (" \\ .\\ " , ' /' ).c_str (), " /" );
244+ EXPECT_STREQ (FileSystem::SimplifyPath (" /./" , ' \\ ' ).c_str (), " " );
245+ EXPECT_STREQ (FileSystem::SimplifyPath (" \\ .\\ " , ' \\ ' ).c_str (), " " );
246+
214247 EXPECT_STREQ (FileSystem::SimplifyPath (" ./a" , ' /' ).c_str (), " a" );
215248 EXPECT_STREQ (FileSystem::SimplifyPath (" .\\ a" , ' /' ).c_str (), " a" );
216249 EXPECT_STREQ (FileSystem::SimplifyPath (" ./a" , ' \\ ' ).c_str (), " a" );
@@ -272,6 +305,57 @@ TEST(Platforms_FileSystem, SimplifyPath)
272305 EXPECT_STREQ (FileSystem::SimplifyPath (" ..\\ .." , ' /' ).c_str (), " ../.." );
273306 EXPECT_STREQ (FileSystem::SimplifyPath (" ../.." , ' \\ ' ).c_str (), " ..\\ .." );
274307 EXPECT_STREQ (FileSystem::SimplifyPath (" ..\\ .." , ' \\ ' ).c_str (), " ..\\ .." );
308+
309+ EXPECT_STREQ (FileSystem::SimplifyPath (" /../.." , ' /' ).c_str (), " /" );
310+ EXPECT_STREQ (FileSystem::SimplifyPath (" \\ ..\\ .." , ' /' ).c_str (), " /" );
311+ EXPECT_STREQ (FileSystem::SimplifyPath (" /../.." , ' \\ ' ).c_str (), " ..\\ .." );
312+ EXPECT_STREQ (FileSystem::SimplifyPath (" \\ ..\\ .." , ' \\ ' ).c_str (), " ..\\ .." );
313+
314+ EXPECT_STREQ (FileSystem::SimplifyPath (" /../../a" , ' /' ).c_str (), " /a" );
315+ EXPECT_STREQ (FileSystem::SimplifyPath (" \\ ..\\ ..\\ a" , ' /' ).c_str (), " /a" );
316+ EXPECT_STREQ (FileSystem::SimplifyPath (" /../../a" , ' \\ ' ).c_str (), " ..\\ ..\\ a" );
317+ EXPECT_STREQ (FileSystem::SimplifyPath (" \\ ..\\ ..\\ a" , ' \\ ' ).c_str (), " ..\\ ..\\ a" );
318+
319+ EXPECT_STREQ (FileSystem::SimplifyPath (" c:/../.." , ' /' ).c_str (), " .." );
320+ EXPECT_STREQ (FileSystem::SimplifyPath (" c:\\ ..\\ .." , ' /' ).c_str (), " .." );
321+ EXPECT_STREQ (FileSystem::SimplifyPath (" c:/../.." , ' \\ ' ).c_str (), " c:" );
322+ EXPECT_STREQ (FileSystem::SimplifyPath (" c:\\ ..\\ .." , ' \\ ' ).c_str (), " c:" );
323+
324+ EXPECT_STREQ (FileSystem::SimplifyPath (" c:/../../a" , ' /' ).c_str (), " ../a" );
325+ EXPECT_STREQ (FileSystem::SimplifyPath (" c:\\ ..\\ ..\\ a" , ' /' ).c_str (), " ../a" );
326+ EXPECT_STREQ (FileSystem::SimplifyPath (" c:/../../a" , ' \\ ' ).c_str (), " c:\\ a" );
327+ EXPECT_STREQ (FileSystem::SimplifyPath (" c:\\ ..\\ ..\\ a" , ' \\ ' ).c_str (), " c:\\ a" );
328+
329+ EXPECT_STREQ (FileSystem::SimplifyPath (" //server/../.." , ' /' ).c_str (), " /" );
330+ EXPECT_STREQ (FileSystem::SimplifyPath (" \\\\ server\\ ..\\ .." , ' /' ).c_str (), " /" );
331+ EXPECT_STREQ (FileSystem::SimplifyPath (" //server/../.." , ' \\ ' ).c_str (), " \\\\ server" );
332+ EXPECT_STREQ (FileSystem::SimplifyPath (" \\\\ server\\ ..\\ .." , ' \\ ' ).c_str (), " \\\\ server" );
333+
334+ EXPECT_STREQ (FileSystem::SimplifyPath (" /a/.." , ' /' ).c_str (), " /" );
335+ EXPECT_STREQ (FileSystem::SimplifyPath (" \\ a\\ .." , ' /' ).c_str (), " /" );
336+ EXPECT_STREQ (FileSystem::SimplifyPath (" /a/.." , ' \\ ' ).c_str (), " " );
337+ EXPECT_STREQ (FileSystem::SimplifyPath (" \\ a\\ .." , ' \\ ' ).c_str (), " " );
338+
339+ // Drive-relative paths are treated as drive-rooted
340+ EXPECT_STREQ (FileSystem::SimplifyPath (" c:foo" , ' \\ ' ).c_str (), " c:\\ foo" );
341+ EXPECT_STREQ (FileSystem::SimplifyPath (" c:.\\ foo" , ' \\ ' ).c_str (), " c:\\ foo" );
342+ EXPECT_STREQ (FileSystem::SimplifyPath (" c:..\\ foo" , ' \\ ' ).c_str (), " c:\\ foo" );
343+
344+ // UNC with share name
345+ EXPECT_STREQ (FileSystem::SimplifyPath (" //server/share" , ' /' ).c_str (), " /server/share" );
346+ EXPECT_STREQ (FileSystem::SimplifyPath (" //server/share" , ' \\ ' ).c_str (), " \\\\ server\\ share" );
347+ EXPECT_STREQ (FileSystem::SimplifyPath (" //server/share/.." , ' /' ).c_str (), " /server" );
348+ EXPECT_STREQ (FileSystem::SimplifyPath (" //server/share/.." , ' \\ ' ).c_str (), " \\\\ server" );
349+ EXPECT_STREQ (FileSystem::SimplifyPath (" //server/share/../a" , ' /' ).c_str (), " /server/a" );
350+ EXPECT_STREQ (FileSystem::SimplifyPath (" //server/share/../a" , ' \\ ' ).c_str (), " \\\\ server\\ a" );
351+ EXPECT_STREQ (FileSystem::SimplifyPath (" //server/share/../../a" , ' /' ).c_str (), " /a" );
352+ EXPECT_STREQ (FileSystem::SimplifyPath (" //server/share/../../a" , ' \\ ' ).c_str (), " \\\\ server\\ a" );
353+
354+ // Mixed slashes in UNC paths
355+ EXPECT_STREQ (FileSystem::SimplifyPath (" \\\\ server/share" , ' /' ).c_str (), " /server/share" );
356+ EXPECT_STREQ (FileSystem::SimplifyPath (" \\\\ server/share" , ' \\ ' ).c_str (), " \\\\ server\\ share" );
357+ EXPECT_STREQ (FileSystem::SimplifyPath (" //server\\ share/./a" , ' /' ).c_str (), " /server/share/a" );
358+ EXPECT_STREQ (FileSystem::SimplifyPath (" //server\\ share/./a" , ' \\ ' ).c_str (), " \\\\ server\\ share\\ a" );
275359}
276360
277361TEST (Platforms_FileSystem, SplitPathList)
0 commit comments