-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f472596
commit e1b7d31
Showing
3 changed files
with
35 additions
and
7 deletions.
There are no files selected for viewing
29 changes: 28 additions & 1 deletion
29
common/src/test/kotlin/br/com/stonks/common/formatters/CurrencyFormatterTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,41 @@ | ||
package br.com.stonks.common.formatters | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import kotlin.test.assertEquals | ||
|
||
class CurrencyFormatterTest { | ||
|
||
private val delta = 0.0 | ||
|
||
@Test | ||
fun `given currency formatter then return value with parametrized locale`() { | ||
val result = 16.00.formatCurrency() | ||
|
||
assertEquals("R\$ 16,00", result) | ||
} | ||
|
||
@Test | ||
fun `given currency formatter when convert invalid value then return default zero`() { | ||
assertEquals(0.0, "lorem".toCurrency(), delta) | ||
} | ||
|
||
@Test | ||
fun `given currency formatter when convert with partially invalid value then return only numbers`() { | ||
assertEquals(0.14, "14B".toCurrency(), delta) | ||
} | ||
|
||
@Test | ||
fun `given currency formatter when convert value with symbol then return currency value`() { | ||
assertEquals(0.14, "R$ 0,14".toCurrency(), delta) | ||
} | ||
|
||
@Test | ||
fun `given currency formatter when convert value with format numbers then return currency value`() { | ||
assertEquals(0.14, "0,14".toCurrency(), delta) | ||
} | ||
|
||
@Test | ||
fun `given currency formatter when convert value with only numbers then return currency value`() { | ||
assertEquals(0.14, "14".toCurrency(), delta) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters