| 213 | | [self testLaxContext:@"@example.com" withURI:@"example.com"]; |
|---|
| 214 | | |
|---|
| 215 | | [self testLaxContext:@"foo (bar) http://example.com/path/to/url.html" withURI:@"http://example.com/path/to/url.html"]; |
|---|
| | 214 | [self testLaxContext:@"@%@" withURI:@"example.com"]; |
|---|
| | 215 | |
|---|
| | 216 | [self testLaxContext:@"foo (bar) %@" withURI:@"http://example.com/path/to/url.html"]; |
|---|
| | 217 | } |
|---|
| | 218 | |
|---|
| | 219 | - (void)testCompositContext { |
|---|
| | 220 | NSString *URI1 = @"mailto:test@example.com"; |
|---|
| | 221 | NSString *URI2 = @"xmpp:test@example.com"; |
|---|
| | 222 | NSString *testString = [NSString stringWithFormat:@"%@ something %@", URI1, URI2]; |
|---|
| | 223 | AHHyperlinkScanner *scanner = [AHHyperlinkScanner hyperlinkScannerWithString:testString]; |
|---|
| | 224 | AHMarkedHyperlink *link; |
|---|
| | 225 | |
|---|
| | 226 | link = [scanner nextURI]; |
|---|
| | 227 | STAssertNotNil(link, @"-[SHHyperlinkScanner nextURL] found no URI in \"%@\"", testString); |
|---|
| | 228 | STAssertEqualObjects([[link parentString] substringWithRange:[link range]], URI1, @"in context: '%@'", testString); |
|---|
| | 229 | |
|---|
| | 230 | link = [scanner nextURI]; |
|---|
| | 231 | STAssertNotNil(link, @"-[SHHyperlinkScanner nextURL] found no URI in \"%@\"", testString); |
|---|
| | 232 | STAssertEqualObjects([[link parentString] substringWithRange:[link range]], URI2, @"in context: '%@'", testString); |
|---|