Skip to content

Commit

Permalink
fixed #11926 (Treat MacOS filesystem as case insensitive) / TestPath:…
Browse files Browse the repository at this point in the history
… added more tests
  • Loading branch information
firewave committed Sep 7, 2023
1 parent ce78017 commit 9605577
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@


/** Is the filesystem case insensitive? */
static bool caseInsensitiveFilesystem()
static constexpr bool caseInsensitiveFilesystem()
{
#ifdef _WIN32
#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__))
// Windows is case insensitive
// MacOS is case insensitive by default (also supports case sensitivity)
return true;
#else
// TODO: Non-windows filesystems might be case insensitive
Expand Down
3 changes: 2 additions & 1 deletion releasenotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ Deprecations:
Other:
- "USE_QT6=On" will no longer fallback to Qt5 when Qt6 is not found.
- When the execution of an addon fails with an exitcode it will now result in an 'internalError' instead of being silently ignored.
- "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.
- "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.
- The MacOS filesystem is now treated as case insensitive.
49 changes: 49 additions & 0 deletions test/testpath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class TestPath : public TestFixture {
TEST_CASE(join);
TEST_CASE(isDirectory);
TEST_CASE(isFile);
TEST_CASE(sameFileName);
TEST_CASE(getFilenameExtension);
}

void removeQuotationMarks() const {
Expand Down Expand Up @@ -176,6 +178,53 @@ class TestPath : public TestFixture {
ASSERT_EQUALS(true, Path::isFile("testpath/testpath.txt"));
ASSERT_EQUALS(true, Path::isFile("testpath2.txt"));
}

void sameFileName() const {
ASSERT(Path::sameFileName("test", "test"));

// case sensitivity cases
#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__))
ASSERT(Path::sameFileName("test", "Test"));
ASSERT(Path::sameFileName("test", "TesT"));
ASSERT(Path::sameFileName("test.h", "test.H"));
ASSERT(Path::sameFileName("test.hh", "test.Hh"));
ASSERT(Path::sameFileName("test.hh", "test.hH"));
#else
ASSERT(!Path::sameFileName("test", "Test"));
ASSERT(!Path::sameFileName("test", "TesT"));
ASSERT(!Path::sameFileName("test.h", "test.H"));
ASSERT(!Path::sameFileName("test.hh", "test.Hh"));
ASSERT(!Path::sameFileName("test.hh", "test.hH"));
#endif
}

void getFilenameExtension() const {
ASSERT_EQUALS("", Path::getFilenameExtension("test"));
ASSERT_EQUALS("", Path::getFilenameExtension("Test"));
ASSERT_EQUALS(".h", Path::getFilenameExtension("test.h"));
ASSERT_EQUALS(".h", Path::getFilenameExtension("Test.h"));
ASSERT_EQUALS("", Path::getFilenameExtension("test", true));
ASSERT_EQUALS("", Path::getFilenameExtension("Test", true));
ASSERT_EQUALS(".h", Path::getFilenameExtension("test.h", true));
ASSERT_EQUALS(".h", Path::getFilenameExtension("Test.h", true));

// case sensitivity cases
#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__))
ASSERT_EQUALS(".h", Path::getFilenameExtension("test.H"));
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.Hh"));
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.hH"));
ASSERT_EQUALS(".h", Path::getFilenameExtension("test.H", true));
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.Hh", true));
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.hH", true));
#else
ASSERT_EQUALS(".H", Path::getFilenameExtension("test.H"));
ASSERT_EQUALS(".Hh", Path::getFilenameExtension("test.Hh"));
ASSERT_EQUALS(".hH", Path::getFilenameExtension("test.hH"));
ASSERT_EQUALS(".h", Path::getFilenameExtension("test.H", true));
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.Hh", true));
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.hH", true));
#endif
}
};

REGISTER_TEST(TestPath)

0 comments on commit 9605577

Please sign in to comment.