问题
I am testing i18n formatting using unit tests in my Grails 4.0.1 application but seeing strange results. To me, this specs condition should be satisfied, but it is not.
I don't suppose anyone has had a similar experience that can be explained, or maybe it's simply a bug? Any help would be appreciated.
回答1:
Just as an idea:
Can you iterate over both expected and actual values and convert the characters one by one to the ascii so that you'll probably see the difference
for( c in '123 456,78 $') {
println "$c ${(int)c}"
}
回答2:
It was suggested that I get the hex value of each side after which it became clear that the formatter was using a non-breaking line space c2a0
whereas my "expected" value was using the standard kind 20
.
I have solved this by using non-breaking spaces on the "expected" side which can be achieved on the Mac by holding Alt
+ space
button as per below.
来源:https://stackoverflow.com/questions/59946271/grails-4-0-1-spock-unit-test-cases-fail-because-of-spaces