Cherry-picked from adium [83fc8295eb5d]: Unit test for new string escaping case
authorStephen Holt <sholt@adium.im>
Sat, 22 Aug 2009 23:10:25 -0400
changeset 2596 387091087c49
parent 2595 93a9f221c29d
child 2597 07e07f9788a6
Cherry-picked from adium [83fc8295eb5d]: Unit test for new string escaping case
Frameworks/AutoHyperlinks Framework/UnitTests/HyperlinkContextTest.m
--- a/Frameworks/AutoHyperlinks Framework/UnitTests/HyperlinkContextTest.m	Sat Aug 22 18:58:10 2009 -0400
+++ b/Frameworks/AutoHyperlinks Framework/UnitTests/HyperlinkContextTest.m	Sat Aug 22 23:10:25 2009 -0400
@@ -27,6 +27,16 @@
 	STAssertEqualObjects([[link parentString] substringWithRange:[link range]], nil, @"in context: '%@'", testString);
 }
 
+- (void)testURIEscaping:(NSString *)URIString
+{
+	NSString	*testString = [NSString stringWithFormat:@"%@", URIString];
+	AHHyperlinkScanner	*scanner = [AHHyperlinkScanner hyperlinkScannerWithString:URIString];
+	AHMarkedHyperlink	*link = [scanner nextURI];
+	
+	STAssertNotNil(link, @"-[SHHyperlinkScanner nextURL] found no URI in \"%@\"", URIString);
+	STAssertEqualObjects([[link URL] absoluteString], URIString, @"in context: '%@'", URIString);
+}
+
 #pragma mark positive tests
 - (void)testEnclosedURI:(NSString *)URIString {
 	[self testLaxContext:@"<%@>" withURI:URIString];
@@ -218,6 +228,8 @@
 	[self testLaxContext:@"foo (bar) %@" withURI:@"http://example.com/path/to/url.html"];
 	
 	[self testLaxContext:@"%@" withURI:[NSString stringWithFormat:@"%@",@"http://example.com/hi%uthere"]]; //#11160
+	
+	[self testURIEscaping:[NSString stringWithFormat:@"%@",@"http://www.google.com/search?q=foo%20bar"]]; //#12850
 }
 
 - (void)testCompositeContext {