Updated on 2026-08-14

This commit is contained in:
Tangem 2026-05-07 11:52:34 +04:00
commit 7378429e90
3 changed files with 76 additions and 11 deletions

View file

@ -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())
}
}