Better fix for *_stringForCharacterAtIndex's missing prototype

This commit is contained in:
Patrice Levesque
2016-02-10 11:29:43 -05:00
parent 5539b7a823
commit d2695bab82
2 changed files with 30 additions and 32 deletions
-2
View File
@@ -54,8 +54,6 @@
- (BOOL) run;
NSString *_stringForCharacterAtIndex(NSUInteger index, NSString *str, NSUInteger length);
- (NSString*) stringFromDiffBetween: (NSString*) str1
and: (NSString*) str2;
@end
+30 -30
View File
@@ -31,6 +31,36 @@
static NSString *SOGoTestAssertException = @"SOGoTestAssertException";
/* Helper function for diffForString:andString */
static NSString *_stringForCharacterAtIndex(NSUInteger index, NSString *str, NSUInteger length)
{
NSString *chrStr;
unichar chr;
if (index < length)
{
chr = [str characterAtIndex: index];
if (isprint(chr))
{
chrStr = [NSString stringWithFormat: @"%c", chr];
}
else
{
if (chr == 10)
chrStr = @"[NL]";
else if (chr == 0)
chrStr = @"[\0]";
else
chrStr = [NSString stringWithFormat: @"[NP: %u]", chr];
}
}
else
{
chrStr = @"[none]";
}
return chrStr;
}
@implementation SOGoTest
+ (NSArray *) allTestClasses
@@ -186,36 +216,6 @@ static NSString *SOGoTestAssertException = @"SOGoTestAssertException";
return YES;
}
/* Helper function for diffForString:andString */
NSString *_stringForCharacterAtIndex(NSUInteger index, NSString *str, NSUInteger length)
{
NSString *chrStr;
unichar chr;
if (index < length)
{
chr = [str characterAtIndex: index];
if (isprint(chr))
{
chrStr = [NSString stringWithFormat: @"%c", chr];
}
else
{
if (chr == 10)
chrStr = @"[NL]";
else if (chr == 0)
chrStr = @"[\0]";
else
chrStr = [NSString stringWithFormat: @"[NP: %u]", chr];
}
}
else
{
chrStr = @"[none]";
}
return chrStr;
}
/*
Returns a string with a very verbose diff of the two strings.
In case the strings are equal it returns an empty string.