Skip to content

Commit 3cbbb77

Browse files
authored
fixed #11926 (Treat MacOS filesystem as case insensitive) / TestPath: added more tests (#5412)
1 parent 4d5e84a commit 3cbbb77

3 files changed

Lines changed: 57 additions & 5 deletions

File tree

lib/path.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@
4646

4747

4848
/** Is the filesystem case insensitive? */
49-
static bool caseInsensitiveFilesystem()
49+
static constexpr bool caseInsensitiveFilesystem()
5050
{
51-
#ifdef _WIN32
51+
#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__))
52+
// Windows is case insensitive
53+
// MacOS is case insensitive by default (also supports case sensitivity)
5254
return true;
5355
#else
5456
// TODO: Non-windows filesystems might be case insensitive

releasenotes.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ Deprecations:
2525
Other:
2626
- "USE_QT6=On" will no longer fallback to Qt5 when Qt6 is not found.
2727
- When the execution of an addon fails with an exitcode it will now result in an 'internalError' instead of being silently ignored.
28-
- "Win32" configurations have been removed from the bundled Visual Studio solution and projects. You might still be able to build 32-bit binaries using CMake but that is untested and unmaintained.
28+
- "Win32" configurations have been removed from the bundled Visual Studio solution and projects. You might still be able to build 32-bit binaries using CMake but that is untested and unmaintained.
29+
- The MacOS filesystem is now treated as case insensitive.

test/testpath.cpp

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class TestPath : public TestFixture {
4242
TEST_CASE(join);
4343
TEST_CASE(isDirectory);
4444
TEST_CASE(isFile);
45+
TEST_CASE(sameFileName);
46+
TEST_CASE(getFilenameExtension);
4547
}
4648

4749
void removeQuotationMarks() const {
@@ -123,7 +125,7 @@ class TestPath : public TestFixture {
123125
ASSERT(Path::isC("C:\\foo\\index.c"));
124126

125127
// In unix .C is considered C++
126-
#ifdef _WIN32
128+
#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__))
127129
ASSERT_EQUALS(true, Path::isC("C:\\foo\\index.C"));
128130
#else
129131
ASSERT_EQUALS(false, Path::isC("C:\\foo\\index.C"));
@@ -134,7 +136,7 @@ class TestPath : public TestFixture {
134136
ASSERT(Path::isCPP("index.c")==false);
135137

136138
// In unix .C is considered C++
137-
#ifdef _WIN32
139+
#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__))
138140
ASSERT_EQUALS(false, Path::isCPP("index.C"));
139141
#else
140142
ASSERT_EQUALS(true, Path::isCPP("index.C"));
@@ -176,6 +178,53 @@ class TestPath : public TestFixture {
176178
ASSERT_EQUALS(true, Path::isFile("testpath/testpath.txt"));
177179
ASSERT_EQUALS(true, Path::isFile("testpath2.txt"));
178180
}
181+
182+
void sameFileName() const {
183+
ASSERT(Path::sameFileName("test", "test"));
184+
185+
// case sensitivity cases
186+
#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__))
187+
ASSERT(Path::sameFileName("test", "Test"));
188+
ASSERT(Path::sameFileName("test", "TesT"));
189+
ASSERT(Path::sameFileName("test.h", "test.H"));
190+
ASSERT(Path::sameFileName("test.hh", "test.Hh"));
191+
ASSERT(Path::sameFileName("test.hh", "test.hH"));
192+
#else
193+
ASSERT(!Path::sameFileName("test", "Test"));
194+
ASSERT(!Path::sameFileName("test", "TesT"));
195+
ASSERT(!Path::sameFileName("test.h", "test.H"));
196+
ASSERT(!Path::sameFileName("test.hh", "test.Hh"));
197+
ASSERT(!Path::sameFileName("test.hh", "test.hH"));
198+
#endif
199+
}
200+
201+
void getFilenameExtension() const {
202+
ASSERT_EQUALS("", Path::getFilenameExtension("test"));
203+
ASSERT_EQUALS("", Path::getFilenameExtension("Test"));
204+
ASSERT_EQUALS(".h", Path::getFilenameExtension("test.h"));
205+
ASSERT_EQUALS(".h", Path::getFilenameExtension("Test.h"));
206+
ASSERT_EQUALS("", Path::getFilenameExtension("test", true));
207+
ASSERT_EQUALS("", Path::getFilenameExtension("Test", true));
208+
ASSERT_EQUALS(".h", Path::getFilenameExtension("test.h", true));
209+
ASSERT_EQUALS(".h", Path::getFilenameExtension("Test.h", true));
210+
211+
// case sensitivity cases
212+
#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__))
213+
ASSERT_EQUALS(".h", Path::getFilenameExtension("test.H"));
214+
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.Hh"));
215+
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.hH"));
216+
ASSERT_EQUALS(".h", Path::getFilenameExtension("test.H", true));
217+
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.Hh", true));
218+
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.hH", true));
219+
#else
220+
ASSERT_EQUALS(".H", Path::getFilenameExtension("test.H"));
221+
ASSERT_EQUALS(".Hh", Path::getFilenameExtension("test.Hh"));
222+
ASSERT_EQUALS(".hH", Path::getFilenameExtension("test.hH"));
223+
ASSERT_EQUALS(".h", Path::getFilenameExtension("test.H", true));
224+
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.Hh", true));
225+
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.hH", true));
226+
#endif
227+
}
179228
};
180229

181230
REGISTER_TEST(TestPath)

0 commit comments

Comments
 (0)