views:

179

answers:

3

Using nUnit to test the output (currency formatting) for a specific culture but we are getting the following result.

  Fail: Formatting currency amount
  String lengths are both 11. Strings differ at index 2.
  Expected: "12 765,87 €"
  But was:  "12 765,87 €"
  -------------^

We can't see the difference between the strings. Our expected result uses a "Space" character.

Is there a different space character that we can put into the accepted result to get the test to pass?

By the way, the tested culture is fr-FR.

Edit: Thanks Adam you are spot on with the unicode character. We have changed our expected results and now each Unit test passes.

A: 

Can you post the ascii code of the char at index two in both strings?

Mark S. Rasmussen
+3  A: 

It's possible they're different types of spaces. Unicode has a lot of different space characters. Take a look at the code points at index 2 by casting the characters to integers to get your answer.

Edit

In response to your comment, code point 160 is a non-breaking space. You can enter it directly into your source code (e.g. Alt+0160 on the numeric keypad on Windows), or use an escape sequence:

// U+20AC is the Unicode code point for the euro sign
string expected = "12\u00A0765,87 \u20AC";
Adam Rosenfield
it is character 160 which appears to be a space ... how can we incorporate this into our "expected" result?
A: 

Most likely it's a character that is blank, but not a space, to avoid labels and such to break the number in two when word-wrapping is enabled.

Lasse V. Karlsen