mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-19 22:33:48 -07:00
YamlConfiguration now correctly writes extra blank lines at the end if requested
By: Nathan Adams <dinnerbone@dinnerbone.com>
This commit is contained in:
@@ -6,7 +6,6 @@ import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
import org.bukkit.configuration.MemoryConfigurationTest;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
@@ -31,7 +31,7 @@ public class YamlConfigurationTest extends FileConfigurationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveToStringWithheader() {
|
||||
public void testSaveToStringWithHeader() {
|
||||
YamlConfiguration config = getConfig();
|
||||
config.options().header("This is a sample\nheader.");
|
||||
|
||||
@@ -45,6 +45,21 @@ public class YamlConfigurationTest extends FileConfigurationTest {
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveToStringWithLongHeader() {
|
||||
YamlConfiguration config = getConfig();
|
||||
config.options().header("This is a sample\nheader.\n\nNewline above should be commented.\n\n");
|
||||
|
||||
for (Map.Entry<String, Object> entry : getTestValues().entrySet()) {
|
||||
config.set(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
String result = config.saveToString();
|
||||
String expected = "# This is a sample\n# header.\n# \n# Newline above should be commented.\n\n\n" + getTestValuesString();
|
||||
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveToStringWithIndent() {
|
||||
YamlConfiguration config = getConfig();
|
||||
|
Reference in New Issue
Block a user