ppkarwasz commented on code in PR #781:
URL: https://github.com/apache/commons-io/pull/781#discussion_r2342397696
##########
src/test/java/org/apache/commons/io/FileSystemTest.java:
##########
@@ -128,6 +190,42 @@ void testSorted() {
}
}
+ @Test
+ void testMaxNameLength_MatchesRealSystem(@TempDir Path tempDir) {
+ final FileSystem fs = FileSystem.getCurrent();
+ final String[] validNames;
+ switch (fs) {
+ case MAC_OSX:
+ case LINUX:
+ validNames = new String[] { FILE_NAME_255_ASCII,
FILE_NAME_255_UTF8_BYTES };
+ break;
+ case WINDOWS:
+ validNames = new String[] { FILE_NAME_255_ASCII,
FILE_NAME_255_UTF16_CODE_UNITS};
+ break;
+ default:
+ throw new IllegalStateException("Unexpected value: " + fs);
+ }
+ for (final String fileName : validNames) {
+ assertDoesNotThrow(() -> testFileName(tempDir, fileName), "OS
accepts max length name");
+ assertTrue(fs.isLegalFileName(fileName, UTF_8), "Commons IO
accepts max length name");
+ final String tooLongName = fileName + "a";
+ assertThrows(IOException.class, () -> testFileName(tempDir,
tooLongName), "OS rejects too-long name");
+ assertFalse(fs.isLegalFileName(tooLongName, UTF_8), "Commons IO
rejects too-long name");
+ }
+ }
Review Comment:
I modified the tests in
https://github.com/apache/commons-io/pull/781/commits/087654e6067daaae8d9309d6351df9603596ed68
to work both on HFS+ and APFS, but a confirmation that it works on APFS would
be nice.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]