summaryrefslogtreecommitdiff
path: root/taler-kotlin-android/src/test/java/net/taler
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2024-03-14 10:11:54 -0600
committerTorsten Grote <t@grobox.de>2024-03-27 14:26:45 -0300
commit881eeabd3999c75c1961eacb2921b41d3a8f58bb (patch)
treeec00d7951705b2b2e79024d604a93e948211da13 /taler-kotlin-android/src/test/java/net/taler
parent5b6ba02e4e3026d08807431b144c5b3c1125266c (diff)
downloadtaler-android-881eeabd3999c75c1961eacb2921b41d3a8f58bb.tar.gz
taler-android-881eeabd3999c75c1961eacb2921b41d3a8f58bb.tar.bz2
taler-android-881eeabd3999c75c1961eacb2921b41d3a8f58bb.zip
[taler-android] Improve handling of currencies with no symbol
(cherry picked from commit c9371584fedf8783ab472d32deb35b24b0329cab)
Diffstat (limited to 'taler-kotlin-android/src/test/java/net/taler')
-rw-r--r--taler-kotlin-android/src/test/java/net/taler/common/AmountTest.kt28
1 files changed, 26 insertions, 2 deletions
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
index 8a92764..1ea4e70 100644
--- a/taler-kotlin-android/src/test/java/net/taler/common/AmountTest.kt
+++ b/taler-kotlin-android/src/test/java/net/taler/common/AmountTest.kt
@@ -150,6 +150,23 @@ class AmountTest {
currency = "EUR",
symbol = "€",
)
+
+ amountToString(
+ amount = Amount.fromString("NOSYMBOL", "13.24"),
+ spec = CurrencySpecification(
+ name = "No symbol!",
+ numFractionalInputDigits = 2,
+ numFractionalNormalDigits = 2,
+ numFractionalTrailingZeroDigits = 2,
+ altUnitNames = mapOf(),
+ ),
+ rawStr = "13.24",
+ fraction = 24000000,
+ specAmount = "13.24",
+ noSpecAmount = "13.24",
+ currency = "NOSYMBOL",
+ symbol = "NOSYMBOL",
+ )
}
private fun amountToString(
@@ -182,10 +199,17 @@ class AmountTest {
// The amount with currency spec
val withSpec = amount.withSpec(spec)
- assertEquals("${symbol}$specAmount", withSpec.toString(symbols = symbols))
assertEquals(specAmount, withSpec.toString(symbols = symbols, showSymbol = false))
- assertEquals("-${symbol}$specAmount", withSpec.toString(symbols = symbols, negative = true))
+ 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) {
+ 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))
+ }
}
@Test