From ed19e5625b3042a3911a6a27d827c7b57f095647 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 15 Sep 2021 13:10:25 +0200 Subject: [PATCH] Fix wxFileName unit test under Unix after recent changes Don't use GetVolumeSeparator() to combine UNC or GUID volumes with paths, this doesn't work because this kind of paths doesn't contain colons at all. Update the documentation to mention this. --- interface/wx/filename.h | 8 ++++++++ tests/filename/filenametest.cpp | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/interface/wx/filename.h b/interface/wx/filename.h index d8ffcb16e7..a24ee7873d 100644 --- a/interface/wx/filename.h +++ b/interface/wx/filename.h @@ -877,6 +877,14 @@ public: /** Returns the string separating the volume from the path for this format. + + Note that for @c wxPATH_DOS paths this string can only be used for + single-character volumes representing the drive letters, but not with + the UNC or GUID volumes (see their description in GetVolume() + documentation). For this reason, its use should be avoided, prefer + using wxFileName constructor and Assign() overload taking the volume + and the path as separate arguments to combining the volume and the path + into a single string using the volume separator between them. */ static wxString GetVolumeSeparator(wxPathFormat format = wxPATH_NATIVE); diff --git a/tests/filename/filenametest.cpp b/tests/filename/filenametest.cpp index bebda4e250..c38c9fa442 100644 --- a/tests/filename/filenametest.cpp +++ b/tests/filename/filenametest.cpp @@ -169,7 +169,9 @@ TEST_CASE("wxFileName::Construction", "[filename]") // if the test is run from root directory or its direct subdirectory CHECK( fn.Normalize(wxPATH_NORM_ALL, "/foo/bar/baz", fni.format) ); - if ( *fni.volume && *fni.path ) + // restrict this check to drive letter volumes as UNC and GUID volumes + // can't be combined with the path using the volume separator + if ( strlen(fni.volume) == 1 && *fni.path ) { // check that specifying the volume separately or as part of the // path doesn't make any difference