BAEL-6895 extend String format test to cover negatives

This commit is contained in:
Sam Gardner 2023-10-11 11:09:45 +01:00
parent fe9c78ceb8
commit d4d4a0e1a4
1 changed files with 6 additions and 2 deletions

View File

@ -61,9 +61,13 @@ public class TruncateDoubleUnitTest {
@Test
public void givenADouble_whenUsingStringFormat_truncateToTwoDecimalPlaces() {
double value = 1.55555555;
String truncated = String.format("%.2f", value);
double positive = 1.55555555;
String truncated = String.format("%.2f", positive);
assertEquals("1.56", truncated);
double negative = -1.55555555;
String negativeTruncated = String.format("%.2f", negative);
assertEquals("-1.56", negativeTruncated);
}
}