Add unit tests
This commit is contained in:
parent
d6a8dfc00e
commit
e902d999cd
|
@ -629,10 +629,11 @@ public final class FileUtilities {
|
|||
}
|
||||
|
||||
public static String normalizePathSeparators(String path) {
|
||||
// special handling for UNC paths
|
||||
// special handling for UNC paths (e.g. \\server\share\path)
|
||||
if (path.startsWith(UNC_PREFIX)) {
|
||||
return UNC_PREFIX + replacePathSeparators(path.substring(UNC_PREFIX.length()), "/");
|
||||
return UNC_PREFIX + normalizePathSeparators(path.substring(UNC_PREFIX.length()));
|
||||
}
|
||||
|
||||
return replacePathSeparators(path, "/");
|
||||
}
|
||||
|
||||
|
|
|
@ -48,4 +48,14 @@ public class FileUtilitiesTest {
|
|||
assertFalse(FileUtilities.isDerived(new File("10.z"), new File("1.mp4")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void normalizePathSeparators() {
|
||||
assertEquals("C:/file.txt", FileUtilities.normalizePathSeparators("C:\\file.txt"));
|
||||
assertEquals("/Volume/USB/file.txt", FileUtilities.normalizePathSeparators("/Volume\\USB/file.txt"));
|
||||
|
||||
assertEquals("\\\\server/share/data/file.txt", FileUtilities.normalizePathSeparators("\\\\server\\share\\data\\file.txt"));
|
||||
assertEquals("\\\\server/share/data/file.txt", FileUtilities.normalizePathSeparators("\\\\server\\share\\data\\file.txt"));
|
||||
assertEquals("/server/share/data/file.txt", FileUtilities.normalizePathSeparators("//server/share/data/file.txt"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue