taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

commit 370674c5a06a7b44f9f5547e0a98a1189b8e977e
parent 0b9ed8edded31def455e34e4651188ca39efeb88
Author: Iván Ávalos <avalos@disroot.org>
Date:   Thu,  5 Dec 2024 10:14:54 +0100

[shared] fix Amount test

Diffstat:
Mtaler-kotlin-android/src/main/java/net/taler/common/Amount.kt | 2+-
Mtaler-kotlin-android/src/test/java/net/taler/common/AmountTest.kt | 16+++++++++-------
2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/taler-kotlin-android/src/main/java/net/taler/common/Amount.kt b/taler-kotlin-android/src/main/java/net/taler/common/Amount.kt @@ -273,7 +273,7 @@ data class Amount( val fmt = format.format(amount) return if (showSymbol) { // If no symbol, then we use the currency string - if (spec.symbol != null) fmt else "$fmt $currency" + (if (spec.symbol != null) fmt else "$fmt $currency").trim() } else { // We should do better than manually removing the symbol here fmt.replace(s.currencySymbol, "").trim() diff --git a/taler-kotlin-android/src/test/java/net/taler/common/AmountTest.kt b/taler-kotlin-android/src/test/java/net/taler/common/AmountTest.kt @@ -97,7 +97,7 @@ class AmountTest { rawStr = "23", fraction = 0, specAmount = "23", - noSpecAmount = "23", + noSpecAmount = "23.00", currency = "TESTKUDOS", symbol = "テ", ) @@ -210,13 +210,15 @@ class AmountTest { assertEquals(specAmount, withSpec.toString(symbols = symbols, showSymbol = false)) assertEquals("-$specAmount", withSpec.toString(symbols = symbols, showSymbol = false, negative = true)) assertEquals("-$specAmount", withSpec.toString(symbols = symbols, showSymbol = false, negative = true)) - if (spec.symbol != null) { + + // FIXME: this test is locale-dependent + if (spec.symbol != null) { assertEquals("${symbol}$specAmount", withSpec.toString(symbols = symbols)) - assertEquals("-${symbol}$specAmount", withSpec.toString(symbols = symbols, negative = true)) - } else { - assertEquals("$specAmount $currency", withSpec.toString(symbols = symbols)) - assertEquals("-$specAmount $currency", withSpec.toString(symbols = symbols, negative = true)) - } + assertEquals("-${symbol} $specAmount", withSpec.toString(symbols = symbols, negative = true)) + } else { + assertEquals("$specAmount $currency", withSpec.toString(symbols = symbols)) + assertEquals("-$specAmount $currency", withSpec.toString(symbols = symbols, negative = true)) + } } @Test