Configuration methods .getX (int/double/etc) now try to cast existing values where possible. This fixes BUKKIT-290

By: Nathan Adams <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot
2011-12-12 18:34:26 +00:00
parent f6bfce4fa1
commit efa01d0a28
3 changed files with 113 additions and 8 deletions

View File

@@ -315,9 +315,21 @@ public abstract class ConfigurationSectionTest {
ConfigurationSection section = getConfigurationSection();
String key = "exists";
double value = Double.MAX_VALUE;
section.set(key, value);
assertEquals(value, section.getDouble(key), 1);
assertNull(section.getString("doesntExist"));
}
@Test
public void testGetDoubleFromInt() {
ConfigurationSection section = getConfigurationSection();
String key = "exists";
double value = 123;
section.set(key, (int)value);
assertEquals(value, section.getDouble(key), 1);
assertNull(section.getString("doesntExist"));
}