Updated on 2026-08-14
This commit is contained in:
commit
7378429e90
3 changed files with 76 additions and 11 deletions
|
|
@ -294,4 +294,52 @@ internal class BigDecimalFiatFormatTest {
|
|||
Truth.assertThat(formatted)
|
||||
.isEqualTo("0.00000000000000000000123".addUsdSymbolLeft())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `price zero is formatted with default precision and does not crash`() {
|
||||
val testValue = BigDecimal.ZERO
|
||||
|
||||
val formatted = testValue.format {
|
||||
fiat(
|
||||
fiatCurrencyCode = usdCurrencyCode,
|
||||
fiatCurrencySymbol = usdSymbol,
|
||||
locale = testLocale,
|
||||
).price()
|
||||
}
|
||||
|
||||
Truth.assertThat(formatted)
|
||||
.isEqualTo("0.00".addUsdSymbolLeft())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `price negative integer keeps sign and does not crash`() {
|
||||
val testValue = BigDecimal("-500")
|
||||
|
||||
val formatted = testValue.format {
|
||||
fiat(
|
||||
fiatCurrencyCode = usdCurrencyCode,
|
||||
fiatCurrencySymbol = usdSymbol,
|
||||
locale = testLocale,
|
||||
).price()
|
||||
}
|
||||
|
||||
Truth.assertThat(formatted)
|
||||
.isEqualTo("-" + "500.00".addUsdSymbolLeft())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `price negative fractional keeps sign and does not crash`() {
|
||||
val testValue = BigDecimal("-0.5")
|
||||
|
||||
val formatted = testValue.format {
|
||||
fiat(
|
||||
fiatCurrencyCode = usdCurrencyCode,
|
||||
fiatCurrencySymbol = usdSymbol,
|
||||
locale = testLocale,
|
||||
).price()
|
||||
}
|
||||
|
||||
Truth.assertThat(formatted)
|
||||
.isEqualTo("-" + "0.50".addUsdSymbolLeft())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue