Fix enum parsing from Config files

Change-Id: Ib0b86ceab070d46903de7b55f2fd441714855141
This commit is contained in:
Shawn Pearce 2013-01-11 14:09:02 -08:00
parent 8a63474518
commit 5630686655
2 changed files with 4 additions and 1 deletions

View File

@ -290,6 +290,9 @@ public void testGetEnum() throws ConfigInvalidException {
c = parse("[s \"b\"]\n\tc = one-two\n");
assertSame(TestEnum.ONE_TWO, c.getEnum("s", "b", "c", TestEnum.ONE_TWO));
c = parse("[s \"b\"]\n\tc = one two\n");
assertSame(TestEnum.ONE_TWO, c.getEnum("s", "b", "c", TestEnum.ONE_TWO));
}
@Test

View File

@ -387,7 +387,7 @@ public <T extends Enum<?>> T getEnum(final T[] all, final String section,
if (value == null)
return defaultValue;
String n = value.replace('-', '_');
String n = value.replace('-', '_').replace(' ', '_');
T trueState = null;
T falseState = null;
for (T e : all) {