mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package de.dennisguse.opentracks.util;
|
package de.dennisguse.opentracks.util;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.JUnit4;
|
import org.junit.runners.JUnit4;
|
||||||
@@ -22,8 +24,6 @@ import org.junit.runners.JUnit4;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link FileUtils}.
|
* Tests for {@link FileUtils}.
|
||||||
*
|
*
|
||||||
@@ -101,6 +101,13 @@ public class FileUtilsTest {
|
|||||||
assertEquals(expected, FileUtils.sanitizeFileName(name));
|
assertEquals(expected, FileUtils.sanitizeFileName(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSanitizeFileName_emoji() {
|
||||||
|
String name = "\uD83C\uDF5B-Food";
|
||||||
|
String expected = "_-Food";
|
||||||
|
assertEquals(expected, FileUtils.sanitizeFileName(name));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link FileUtils#truncateFileName(File, String, String)}.
|
* Tests {@link FileUtils#truncateFileName(File, String, String)}.
|
||||||
* Verifies the a long file name is truncated.
|
* Verifies the a long file name is truncated.
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class FileUtils {
|
|||||||
for (int i = 0; i < name.length(); i++) {
|
for (int i = 0; i < name.length(); i++) {
|
||||||
int codePoint = name.codePointAt(i);
|
int codePoint = name.codePointAt(i);
|
||||||
char character = name.charAt(i);
|
char character = name.charAt(i);
|
||||||
if (Character.isLetterOrDigit(character) || codePoint > 127 || isSpecialFat32(character) || character == '.') {
|
if (Character.isLetterOrDigit(character) || isSpecialFat32(character) || character == '.') {
|
||||||
builder.appendCodePoint(codePoint);
|
builder.appendCodePoint(codePoint);
|
||||||
} else {
|
} else {
|
||||||
builder.append("_");
|
builder.append("_");
|
||||||
|
|||||||
Reference in New Issue
Block a user