mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-05 02:22:55 +01:00
parent
f0f87c844e
commit
bc00cce9bd
@ -143,12 +143,12 @@ public final class ResXmlEncoders {
|
||||
}
|
||||
|
||||
public static boolean hasMultipleNonPositionalSubstitutions(String str) {
|
||||
Duo<List<Integer>, List<Integer>> tuple = findSubstitutions(str, 3);
|
||||
Duo<List<Integer>, List<Integer>> tuple = findSubstitutions(str, 4);
|
||||
return ! tuple.m1.isEmpty() && tuple.m1.size() + tuple.m2.size() > 1;
|
||||
}
|
||||
|
||||
public static String enumerateNonPositionalSubstitutionsIfRequired(String str) {
|
||||
Duo<List<Integer>, List<Integer>> tuple = findSubstitutions(str, 3);
|
||||
Duo<List<Integer>, List<Integer>> tuple = findSubstitutions(str, 4);
|
||||
if (tuple.m1.isEmpty() || tuple.m1.size() + tuple.m2.size() < 2) {
|
||||
return str;
|
||||
}
|
||||
|
@ -51,6 +51,16 @@ public class PositionalEnumerationTest {
|
||||
assertEquals(" %1$s, %2$s and %3$d other", enumerateArguments(" %1$s, %2$s and %3$d other"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fourArgumentsTest() {
|
||||
assertEquals("%1$s, %2$s, and %3$d other and %4$d.", enumerateArguments("%s, %s, and %d other and %d."));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fourPositionalArgumentsTest() {
|
||||
assertEquals(" %1$s, %2$s and %3$d other and %4$d.", enumerateArguments(" %1$s, %2$s and %3$d other and %4$d."));
|
||||
}
|
||||
|
||||
private String enumerateArguments(String value) {
|
||||
return ResXmlEncoders.enumerateNonPositionalSubstitutionsIfRequired(value);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user