Monotone-Parent: 1e9c4371dcc93fa8a7f07290f63d3623a276fb8e

Monotone-Revision: 53583144c5d999d03c432c06fcea467dcb2b4988

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-01-07T16:59:41
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2010-01-07 16:59:41 +00:00
parent 063091f72a
commit 1afac41537
3 changed files with 41 additions and 7 deletions
+3
View File
@@ -1,5 +1,8 @@
2010-01-07 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/NSDictionary+BSJSONAdditions.m
(-jsonStringFromString:): convert "\" to "\\" rather than "\n".
* SoObjects/SOGo/NSScanner+BSJSONAdditions.m (-scanJSONString): we
now accept lowercase characters in characters coded in UCN.
@@ -137,7 +137,7 @@ const int jsonDoNotIndent = -1;
[jsonString appendString:@"\\\""];
break;
case '\\':
[jsonString appendString:@"\\n"];
[jsonString appendString:@"\\\\"];
break;
/* TODO: email out to json group on this - spec says to handlt his, examples and example code don't handle this.
case '\/':
+37 -6
View File
@@ -23,26 +23,27 @@
#import <Foundation/NSException.h>
#import <Foundation/NSString.h>
#import <SOGo/NSScanner+BSJSONAdditions.h>
#import "SOGo/NSScanner+BSJSONAdditions.h"
#import "SOGo/NSDictionary+BSJSONAdditions.h"
#import "SOGoTest.h"
@interface TestBSJSONAdditions : SOGoTest
@interface TestNSSCannerBSJSONAdditions : SOGoTest
@end
@implementation TestBSJSONAdditions
@implementation TestNSSCannerBSJSONAdditions
- (void) test_scanJSONString
{
NSScanner *testScanner;
NSString *currentString, *expected, *error;
NSMutableString *resultString;
int count;
NSString *testStrings[] = { @"\"\\\\\"", @"\\",
@"\"\\u0041\"", @"A",
@"\"\\u000A\"", @"\n",
@"\"\\u000a\"", @"\n",
nil };
NSString *currentString, *expected, *error;
NSMutableString *resultString;
int count;
count = 0;
while ((currentString = testStrings[count * 2]))
@@ -60,3 +61,33 @@
}
@end
@interface TestNSDictionaryBSJSONAdditions : SOGoTest
@end
@implementation TestNSDictionaryBSJSONAdditions
- (void) test_jsonStringForString
{
NSDictionary *testDictionary;
NSString *currentString, *resultString, *expected, *error;
int count;
NSString *testStrings[] = { @"\n", @"\"\\n\"",
@"\\", @"\"\\\\\"",
nil };
testDictionary = [NSDictionary dictionary];
count = 0;
while ((currentString = testStrings[count * 2]))
{
resultString = [testDictionary jsonStringForString: currentString];
expected = testStrings[count * 2 + 1];
error = [NSString stringWithFormat:
@"objects '%@' and '%@' differs (count: %d)",
expected, resultString, count];
testEqualsWithMessage(expected, resultString, error);
count++;
}
}
@end