YamlConfiguration now correctly writes extra blank lines at the end if requested

By: Nathan Adams <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot
2011-10-12 04:39:22 +01:00
parent b94e100930
commit ea55a50756
3 changed files with 26 additions and 7 deletions

View File

@@ -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;

View File

@@ -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();