I'm doing tests in android studio for a tutorial and the test results show me this:
expected:<2,00[ ]$> but was:<2,00[ ]$>
Expected :2,00 $
Actual :2,00 $
I'm a bit confused ! both are the same string....
EDIT:
This is the method i'm testing
@VisibleForTesting
internal fun calculateTip(
amount: Double, percent: Double = 15.0, roundUp: Boolean): String{
var tip = percent / 100 * amount
if (roundUp)
tip = kotlin.math.ceil(tip)
return NumberFormat.getCurrencyInstance().format(tip)
}
This is the test assertion:
@Test
fun calculate_20_percent_tip_no_roundup() {
val amount = 10.00
val tipPercent = 20.00
val expectedTip = "2,00 $"
val actualTip = calculateTip(amount = amount, percent = tipPercent, false)
assertEquals(expectedTip, actualTip)
}

