Don't shorten message footers for mixed-direction text.

This commit is contained in:
Greyson Parrelli
2022-02-09 16:08:21 -05:00
committed by GitHub
parent 14db5ce349
commit 9802724baa
3 changed files with 76 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
package org.thoughtcrime.securesms.util;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
import static org.junit.Assert.assertEquals;
@RunWith(Parameterized.class)
public final class StringUtilTest_hasMixedTextDirection {
private final CharSequence input;
private final boolean expected;
@Parameterized.Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{
{ "", false },
{ null, false },
{ "A", false},
{ "ة", false}, // Arabic
{ "ی", false}, // Kurdish
{ "ی", false }, // Farsi
{ "و", false }, // Urdu
{ "ת", false }, // Hebrew
{ "ש", false }, // Yiddish
{ "", true }, // Arabic-ASCII
{ "یA", true }, // Kurdish-ASCII
{ "", true }, // Farsi-ASCII
{ "وA", true }, // Urdu-ASCII
{ "", true }, // Hebrew-ASCII
{ "שA", true }, // Yiddish-ASCII
});
}
public StringUtilTest_hasMixedTextDirection(CharSequence input, boolean expected) {
this.input = input;
this.expected = expected;
}
@Test
public void trim() {
boolean output = StringUtil.hasMixedTextDirection(input);
assertEquals(expected, output);
}
}