mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-19 07:17:37 +01:00
Fix non-replaced placeholders and add test case
This commit is contained in:
parent
ff77738a51
commit
92bcda8f2d
@ -51,12 +51,11 @@ public class StringWithPlaceholders {
|
||||
if (replacement != null) {
|
||||
// Append placeholder replacement
|
||||
output.append(replacement);
|
||||
lastAppendIndex = match.endIndex;
|
||||
} else {
|
||||
// If no replacement is provided, do not replace the occurrence
|
||||
output.append(match.unparsedString);
|
||||
}
|
||||
|
||||
lastAppendIndex = match.endIndex;
|
||||
}
|
||||
|
||||
// Append trailing text (if any)
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.placeholder.parsing;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
@ -34,6 +35,13 @@ class StringWithPlaceholdersTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void skipReplacing() {
|
||||
String input = "{p} a {p} b {p}";
|
||||
StringWithPlaceholders s = new StringWithPlaceholders(input);
|
||||
assertThat(s.replacePlaceholders(occurrence -> null)).isEqualTo(input);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] {0} -> {1}, {2}, {3}")
|
||||
@MethodSource("parsingTestArguments")
|
||||
void parsing(String input, String expectedPluginName, String expectedIdentifier, String expectedArgument) {
|
||||
|
Loading…
Reference in New Issue
Block a user