mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2025-09-05 17:07:06 +02:00
Format to Daddy code style
This commit is contained in:
@@ -20,76 +20,80 @@
|
||||
|
||||
package me.clip.placeholderapi.replacer;
|
||||
|
||||
import me.clip.placeholderapi.Values;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static me.clip.placeholderapi.Values.MockPlayerPlaceholderExpansion.PLAYER_NAME;
|
||||
import static me.clip.placeholderapi.Values.MockPlayerPlaceholderExpansion.PLAYER_X;
|
||||
import static me.clip.placeholderapi.Values.MockPlayerPlaceholderExpansion.PLAYER_Y;
|
||||
import static me.clip.placeholderapi.Values.MockPlayerPlaceholderExpansion.PLAYER_Z;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public final class ReplacerUnitTester
|
||||
{
|
||||
import me.clip.placeholderapi.Values;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Test
|
||||
void testCharsReplacerProducesExpectedSingleValue()
|
||||
{
|
||||
assertEquals(PLAYER_NAME, Values.CHARS_REPLACER.apply("%player_name%", null, Values.PLACEHOLDERS::get));
|
||||
}
|
||||
public final class ReplacerUnitTester {
|
||||
|
||||
@Test
|
||||
void testRegexReplacerProducesExpectedSingleValue()
|
||||
{
|
||||
assertEquals(PLAYER_NAME, Values.REGEX_REPLACER.apply("%player_name%", null, Values.PLACEHOLDERS::get));
|
||||
}
|
||||
@Test
|
||||
void testCharsReplacerProducesExpectedSingleValue() {
|
||||
assertEquals(PLAYER_NAME,
|
||||
Values.CHARS_REPLACER.apply("%player_name%", null, Values.PLACEHOLDERS::get));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCharsReplacerProducesExpectedSentence()
|
||||
{
|
||||
assertEquals(String.format("My name is %s and my location is (%s, %s, %s), this placeholder is invalid %%server_name%%", PLAYER_NAME, PLAYER_X, PLAYER_Y, PLAYER_Z), Values.CHARS_REPLACER.apply(Values.LARGE_TEXT, null, Values.PLACEHOLDERS::get));
|
||||
}
|
||||
@Test
|
||||
void testRegexReplacerProducesExpectedSingleValue() {
|
||||
assertEquals(PLAYER_NAME,
|
||||
Values.REGEX_REPLACER.apply("%player_name%", null, Values.PLACEHOLDERS::get));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRegexReplacerProducesExpectedSentence()
|
||||
{
|
||||
assertEquals(String.format("My name is %s and my location is (%s, %s, %s), this placeholder is invalid %%server_name%%", PLAYER_NAME, PLAYER_X, PLAYER_Y, PLAYER_Z), Values.REGEX_REPLACER.apply(Values.LARGE_TEXT, null, Values.PLACEHOLDERS::get));
|
||||
}
|
||||
@Test
|
||||
void testCharsReplacerProducesExpectedSentence() {
|
||||
assertEquals(String.format(
|
||||
"My name is %s and my location is (%s, %s, %s), this placeholder is invalid %%server_name%%",
|
||||
PLAYER_NAME, PLAYER_X, PLAYER_Y, PLAYER_Z),
|
||||
Values.CHARS_REPLACER.apply(Values.LARGE_TEXT, null, Values.PLACEHOLDERS::get));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testResultsAreTheSameAsReplacement()
|
||||
{
|
||||
final String resultChars = Values.CHARS_REPLACER.apply("%player_name%", null, Values.PLACEHOLDERS::get);
|
||||
final String resultRegex = Values.REGEX_REPLACER.apply("%player_name%", null, Values.PLACEHOLDERS::get);
|
||||
@Test
|
||||
void testRegexReplacerProducesExpectedSentence() {
|
||||
assertEquals(String.format(
|
||||
"My name is %s and my location is (%s, %s, %s), this placeholder is invalid %%server_name%%",
|
||||
PLAYER_NAME, PLAYER_X, PLAYER_Y, PLAYER_Z),
|
||||
Values.REGEX_REPLACER.apply(Values.LARGE_TEXT, null, Values.PLACEHOLDERS::get));
|
||||
}
|
||||
|
||||
assertEquals(resultChars, resultRegex);
|
||||
@Test
|
||||
void testResultsAreTheSameAsReplacement() {
|
||||
final String resultChars = Values.CHARS_REPLACER
|
||||
.apply("%player_name%", null, Values.PLACEHOLDERS::get);
|
||||
final String resultRegex = Values.REGEX_REPLACER
|
||||
.apply("%player_name%", null, Values.PLACEHOLDERS::get);
|
||||
|
||||
assertEquals(PLAYER_NAME, resultChars);
|
||||
}
|
||||
assertEquals(resultChars, resultRegex);
|
||||
|
||||
@Test
|
||||
void testResultsAreTheSameNoReplacement()
|
||||
{
|
||||
final String resultChars = Values.CHARS_REPLACER.apply("%player_location%", null, Values.PLACEHOLDERS::get);
|
||||
final String resultRegex = Values.REGEX_REPLACER.apply("%player_location%", null, Values.PLACEHOLDERS::get);
|
||||
assertEquals(PLAYER_NAME, resultChars);
|
||||
}
|
||||
|
||||
assertEquals(resultChars, resultRegex);
|
||||
}
|
||||
@Test
|
||||
void testResultsAreTheSameNoReplacement() {
|
||||
final String resultChars = Values.CHARS_REPLACER
|
||||
.apply("%player_location%", null, Values.PLACEHOLDERS::get);
|
||||
final String resultRegex = Values.REGEX_REPLACER
|
||||
.apply("%player_location%", null, Values.PLACEHOLDERS::get);
|
||||
|
||||
@Test
|
||||
void testCharsReplacerIgnoresMalformed()
|
||||
{
|
||||
final String text = "10% and %hello world 15%";
|
||||
assertEquals(resultChars, resultRegex);
|
||||
}
|
||||
|
||||
assertEquals(text, Values.CHARS_REPLACER.apply(text, null, Values.PLACEHOLDERS::get));
|
||||
}
|
||||
@Test
|
||||
void testCharsReplacerIgnoresMalformed() {
|
||||
final String text = "10% and %hello world 15%";
|
||||
|
||||
@Test
|
||||
void testCharsReplacerHandlesEscapedHex()
|
||||
{
|
||||
final String text = "\\&xffffffThis should not change.";
|
||||
assertEquals(text, Values.CHARS_REPLACER.apply(text, null, Values.PLACEHOLDERS::get));
|
||||
}
|
||||
|
||||
assertEquals(text.substring(1), Values.CHARS_REPLACER.apply(text, null, Values.PLACEHOLDERS::get));
|
||||
}
|
||||
@Test
|
||||
void testCharsReplacerHandlesEscapedHex() {
|
||||
final String text = "\\&xffffffThis should not change.";
|
||||
|
||||
assertEquals(text.substring(1),
|
||||
Values.CHARS_REPLACER.apply(text, null, Values.PLACEHOLDERS::get));
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user