diff --git a/ChangeLog b/ChangeLog index a0bdc0adc..ed3ffe630 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-04-08 Wolfgang Sourdeau + + * Tests/Unit/TestNSString+URLEscaping.m: new test module. + (-test_stringByEscapingURL): new test method for -[NSString + stringByEscapingURL]. + + * Tests/Unit/sogo-tests.m (main): added volatile user defaults for + utf8 url encoding. + 2011-04-07 Francis Lachapelle * UI/WebServerResources/MailerUI.js (onMenuRenameFolderConfirm): diff --git a/Tests/Unit/GNUmakefile b/Tests/Unit/GNUmakefile index 0fa8ffd2a..f802eafef 100644 --- a/Tests/Unit/GNUmakefile +++ b/Tests/Unit/GNUmakefile @@ -19,7 +19,8 @@ $(TEST_TOOL)_OBJC_FILES += \ \ TestSBJsonParser.m \ \ - TestNGMimeAddressHeaderFieldGenerator.m + TestNGMimeAddressHeaderFieldGenerator.m \ + TestNSString+URLEscaping.m TOOL_NAME = $(TEST_TOOL) diff --git a/Tests/Unit/TestNSString+URLEscaping.m b/Tests/Unit/TestNSString+URLEscaping.m new file mode 100644 index 000000000..8267b2a20 --- /dev/null +++ b/Tests/Unit/TestNSString+URLEscaping.m @@ -0,0 +1,56 @@ +/* TestNSString+URLEscaping.m - this file is part of $PROJECT_NAME_HERE$ + * + * Copyright (C) 2011 Inverse inc + * + * Author: Wolfgang Sourdeau + * + * 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. + */ + +/* This file is encoded in utf-8. */ + +#import + +#import "SOGoTest.h" + +@interface TestNSString_plus_URLEscaping : SOGoTest +@end + +@implementation TestNSString_plus_URLEscaping + +- (void) test_stringByEscapingURL +{ + const char *inStrings[] = { "éléphant", "2š", NULL }; + const char **inString; + NSString *outStrings[] = { @"%C3%A9l%C3%A9phant", @"2%C5%A1" }; + NSString **outString; + NSString *result, *error; + + inString = inStrings; + outString = outStrings; + while (*inString) + { + result = [[NSString stringWithUTF8String: *inString] stringByEscapingURL]; + error = [NSString stringWithFormat: + @"string '%s' badly escaped: '%@' (expected '%@')", + *inString, result, *outString]; + testWithMessage([result isEqualToString: *outString], error); + inString++; + outString++; + } +} + +@end diff --git a/Tests/Unit/sogo-tests.m b/Tests/Unit/sogo-tests.m index 35fb4f4ad..f7189d89e 100644 --- a/Tests/Unit/sogo-tests.m +++ b/Tests/Unit/sogo-tests.m @@ -28,8 +28,20 @@ int main() { NSAutoreleasePool *pool; int rc; + NSDictionary *defaults; + NSUserDefaults *ud; pool = [NSAutoreleasePool new]; + + defaults = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool: YES], + @"NGUseUTF8AsURLEncoding", + nil]; + ud = [NSUserDefaults standardUserDefaults]; + [ud setVolatileDomain: defaults + forName: @"sogo-tests-volatile"]; + [ud addSuiteNamed: @"sogo-tests-volatile"]; + rc = [[SOGoTestRunner testRunner] run]; [pool release];