BAEL-6895 extend String format test to cover negatives
This commit is contained in:
parent
fe9c78ceb8
commit
d4d4a0e1a4
|
@ -61,9 +61,13 @@ public class TruncateDoubleUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenADouble_whenUsingStringFormat_truncateToTwoDecimalPlaces() {
|
public void givenADouble_whenUsingStringFormat_truncateToTwoDecimalPlaces() {
|
||||||
double value = 1.55555555;
|
double positive = 1.55555555;
|
||||||
String truncated = String.format("%.2f", value);
|
String truncated = String.format("%.2f", positive);
|
||||||
assertEquals("1.56", truncated);
|
assertEquals("1.56", truncated);
|
||||||
|
|
||||||
|
double negative = -1.55555555;
|
||||||
|
String negativeTruncated = String.format("%.2f", negative);
|
||||||
|
assertEquals("-1.56", negativeTruncated);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue