I'm creating unit tests for a currency format using intl package last version 0.16.1.
My formatter is: final currencyFormat = NumberFormat.simpleCurrency(locale: 'pt_BR');
My expected result is: var expected = r'R$ 1,00';. And I applied my formatter to value 1.0 in this way: var formatted = currencyFormat.format(1.0) resulting in R$ 1,00.
When I test two values using an expect(formatted, expected), it show me that the results are not the same.
Expected: 'R$ 1,00'
Actual: 'R$ 1,00'
Which: is different.
Expected: R$ 1,00
Actual: R$ 1,00
^
Differ at offset 2
Well, I had take some time to discover that the runes of two strings have one character diff.
expected runes: (82, 36, 32, 49, 44, 48, 48)
formatted runes: (82, 36, 160, 49, 44, 48, 48)
My question is: if is using a Non-breaking space when formatting, how can I avoid this error when there is no documentation talking about it?
Until now, the only way I achieved was put unicode character to my expected string:
var expected = 'R\$\u{00A0}1,00';.This is not a good solution because if we have many formatters inside app and test all that use Non-breaking space we have to put in our expected value the ASCII code.