Monotone-Parent: f36c1a3969587db790c18c96805411a8dfe38f00

Monotone-Revision: 1e9c4371dcc93fa8a7f07290f63d3623a276fb8e

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-01-07T16:37:36
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2010-01-07 16:37:36 +00:00
parent aca76201ad
commit 063091f72a
5 changed files with 82 additions and 3 deletions
+6
View File
@@ -1,5 +1,11 @@
2010-01-07 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/NSScanner+BSJSONAdditions.m (-scanJSONString): we
now accept lowercase characters in characters coded in UCN.
* UnitTests/TestBSJSONAdditions.m: new unit test for
BSJSONAdditions.
* UnitTests/SOGoTest.m: base class for our unit test testcases.
Similar to JUnit and family.
+1 -1
View File
@@ -162,7 +162,7 @@ NSString *jsonNullString = @"null";
/* START Updated code modified from code fix submitted by Bill Garrison - March 28, 2006 - http://www.standardorbit.net */
NSScanner *hexScanner = [NSScanner scannerWithString:digits];
NSString *verifiedHexDigits;
NSCharacterSet *hexDigitSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789ABCDEF"];
NSCharacterSet *hexDigitSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789ABCDEFabcdef"];
if (NO == [hexScanner scanCharactersFromSet:hexDigitSet intoString:&verifiedHexDigits])
return NO;
if (4 != [verifiedHexDigits length])
+11 -1
View File
@@ -1,5 +1,7 @@
# GNUstep makefile
debug=yes
include ../config.make
include $(GNUSTEP_MAKEFILES)/common.make
include ../Version
@@ -9,10 +11,18 @@ $(TEST_TOOL)_INSTALL_DIR = $(SOGO_ADMIN_TOOLS)
$(TEST_TOOL)_OBJC_FILES += \
sogo-tests.m \
\
SOGoTest.m
SOGoTest.m \
\
TestBSJSONAdditions.m
TOOL_NAME = $(TEST_TOOL)
ADDITIONAL_INCLUDE_DIRS += \
-D_GNU_SOURCE -I../SOPE/ -I../SoObjects/ -I../UI/
ADDITIONAL_LIB_DIRS += \
-L../SoObjects/SOGo -lSOGo
-include GNUmakefile.preamble
include $(GNUSTEP_MAKEFILES)/tool.make
-include GNUmakefile.postamble
+2 -1
View File
@@ -24,6 +24,7 @@
#define SOGOTEST_H
#import <Foundation/NSObject.h>
#import <Foundation/NSString.h>
@class NSArray;
@class NSMutableArray;
@@ -71,7 +72,7 @@ typedef enum {
#define testEquals(a,b) \
testWithMessage(([a isEqual: b]), \
([NSString stringWithFormat: @"objects %@ and %@ differs", a, b]))
([NSString stringWithFormat: @"objects '%@' and '%@' differs", (a), (b)]))
#define testEqualsWithMessage(a,b,m) \
testWithMessage(([a isEqual: b]), (m))
+62
View File
@@ -0,0 +1,62 @@
/* BSJSONAdditions.m - this file is part of SOGo
*
* Copyright (C) 2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#import <Foundation/NSException.h>
#import <Foundation/NSString.h>
#import <SOGo/NSScanner+BSJSONAdditions.h>
#import "SOGoTest.h"
@interface TestBSJSONAdditions : SOGoTest
@end
@implementation TestBSJSONAdditions
- (void) test_scanJSONString
{
NSScanner *testScanner;
NSString *testStrings[] = { @"\"\\\\\"", @"\\",
@"\"\\u0041\"", @"A",
@"\"\\u000A\"", @"\n",
@"\"\\u000a\"", @"\n",
nil };
NSString *currentString, *expected, *error;
NSMutableString *resultString;
int count;
count = 0;
while ((currentString = testStrings[count * 2]))
{
resultString = [NSMutableString string];
testScanner = [NSScanner scannerWithString: currentString];
[testScanner scanJSONString: &resultString];
expected = testStrings[count * 2 + 1];
error = [NSString stringWithFormat:
@"objects '%@' and '%@' differs (count: %d)",
expected, resultString, count];
testEqualsWithMessage(expected, resultString, error);
count++;
}
}
@end