I'm writing a discovery test against the Cocoa API as I ramp up on all things Mac related. I'm currently trying to discover the best method for URL encoding a string. Using the Google toolbox for Mac I have a unit test that I intentionally cause a failure in:
NSString* expected = @"ab%%20c";
NSString* encoded = @"ab c";
STAssertEqualStrings(expected, encoded, @"Expected [%s] actual [%s]", [expected UTF8String], [encoded UTF8String]);
and it complains "ab P != ab c" The garbage it dumps in the output is throwing me. It's as if the percent sign isn't properly escaped but I know it is. My main question is how do I get a properly formed error message so I can be sure I'm dealing with apples instead of oranges?
*update Stackoverflow was removing the garbage in my original post. The above failure is intentional to illustrate a problem with the failure message. I'm concerned with the garbage that shows in the failure message as it does cleanly not detail what's in the actual string. The failure says something like "assertion failed ab[apple-symbol]c != ab c" where I get an apple character in the message instead of a percent sign. In practice encoded would be the return of a method call and I'd like to inspect, using the assertion failure message, the contents of the string.