add a few more tests

This commit is contained in:
Michael McCandless 2015-06-01 12:47:12 -04:00 committed by mikemccand
parent 3997ed012b
commit 75d9445323
2 changed files with 30 additions and 0 deletions

View File

@ -104,4 +104,19 @@ public class ByteSizeValueTests extends ElasticsearchTestCase {
public void testFailOnEmptyNumberParsing() {
assertThat(ByteSizeValue.parseBytesSizeValue("g", "emptyNumberParsing").toString(), is("23b"));
}
public void testSpaceAllowed() {
ByteSizeValue result = ByteSizeValue.parseBytesSizeValue("42 gb", "test");
assertEquals(42L*1024*1024*1024, result.bytes());
}
@Test(expected = ElasticsearchParseException.class)
public void testNoDotsAllowed() {
ByteSizeValue.parseBytesSizeValue("42b.", null, "test");
}
public void testCapsAllowed() {
ByteSizeValue result = ByteSizeValue.parseBytesSizeValue("42B", null, "test");
assertEquals(42, result.bytes());
}
}

View File

@ -97,4 +97,19 @@ public class TimeValueTests extends ElasticsearchTestCase {
public void testFailOnMissingUnits() {
TimeValue.parseTimeValue("42", null, "test");
}
public void testSpaceAllowed() {
TimeValue result = TimeValue.parseTimeValue("42 ms", null, "test");
assertEquals(42, result.millis());
}
@Test(expected = ElasticsearchParseException.class)
public void testNoDotsAllowed() {
TimeValue.parseTimeValue("42ms.", null, "test");
}
@Test(expected = ElasticsearchParseException.class)
public void testNoCapsAllowed() {
TimeValue.parseTimeValue("42MS", null, "test");
}
}