Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: f4caa64b85
Fetching contributors…

Cannot retrieve contributors at this time

553 lines (391 sloc) 12.664 kB
//
// TDURLStateTest.m
// ParseKit
//
// Created by Todd Ditchendorf on 3/26/10.
// Copyright 2010 Todd Ditchendorf. All rights reserved.
//
#import "TDURLStateTest.h"
@implementation TDURLStateTest
- (void)setUp {
t = [[PKTokenizer alloc] init];
URLState = t.URLState;
}
- (void)tearDown {
[t release];
}
- (void)testFooComBlahBlah {
s = @"http://foo.com/blah_blah";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testFooComBlahBlahSlash {
s = @"http://foo.com/blah_blah/";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testSomethingLikeFooComBlahBlahSlash {
s = @"(Something like http://foo.com/blah_blah)";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @"(");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isWord);
TDEqualObjects(tok.stringValue, @"Something");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isWord);
TDEqualObjects(tok.stringValue, @"like");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, @"http://foo.com/blah_blah");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @")");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testFooComBlahBlahWiki {
s = @"http://foo.com/blah_blah_(wikipedia)";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testSomethingLikeFooComBlahBlahWiki {
s = @"(Something like http://foo.com/blah_blah_(wikipedia))";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @"(");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isWord);
TDEqualObjects(tok.stringValue, @"Something");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isWord);
TDEqualObjects(tok.stringValue, @"like");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, @"http://foo.com/blah_blah_(wikipedia)");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @")");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testFooComBlahBlahDot {
s = @"http://foo.com/blah_blah.";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, @"http://foo.com/blah_blah");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @".");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testFooComBlahBlahSlashDot {
s = @"http://foo.com/blah_blah/.";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, @"http://foo.com/blah_blah/");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @".");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testLtFooComBlahBlahGt {
s = @"<http://foo.com/blah_blah>";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @"<");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, @"http://foo.com/blah_blah");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @">");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testLtFooComBlahBlahSlashGt {
s = @"<http://foo.com/blah_blah/>";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @"<");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, @"http://foo.com/blah_blah/");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @">");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testExampleComArgDot {
s = @"http://www.example.com/wpstyle/?p=364.";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, @"http://www.example.com/wpstyle/?p=364");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @".");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testStarDF {
s = @"http://✪df.ws/123";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testRadarSlashSlash {
s = @"rdar://1234";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testRadarSlash {
s = @"rdar:/1234";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testUserIdPasswordPort {
s = @"http://userid:password@example.com:8080";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testUserId {
s = @"http://userid@example.com";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testUserIdPort {
s = @"http://userid@example.com:8080";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testUserIdPassword {
s = @"http://userid:password@example.com";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testExampleComPort {
s = @"http://example.com:8080";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testYojimbo {
s = @"x-yojimbo-item://6303E4C1-xxxx-45A6-AB9D-3A908F59AE0E";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testMessage {
s = @"message://%3c330e7f8409726r6a4ba78dkf1fd71420c1bf6ff@mail.gmail.com%3e";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testArrow {
s = @"http://➡.ws/䨹";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testWWWArrow {
s = @"www.➡.ws/䨹";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testFakeWWW {
s = @"wwwp://➡.ws/䨹";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testFakeWW {
s = @"wwp://google.com/䨹";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testFakeW {
s = @"wp://google.com/䨹";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, s);
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testTagExampleComTag {
s = @"<tag>http://example.com</tag>";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @"<");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isWord);
TDEqualObjects(tok.stringValue, @"tag");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @">");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, @"http://example.com");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @"<");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @"/");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isWord);
TDEqualObjects(tok.stringValue, @"tag");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @">");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
- (void)testJustAnExampleComLinkDot {
s = @"Just a www.example.com link.";
t.string = s;
tok = [t nextToken];
TDTrue(tok.isWord);
TDEqualObjects(tok.stringValue, @"Just");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isWord);
TDEqualObjects(tok.stringValue, @"a");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isURL);
TDEqualObjects(tok.stringValue, @"www.example.com");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isWord);
TDEqualObjects(tok.stringValue, @"link");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDTrue(tok.isSymbol);
TDEqualObjects(tok.stringValue, @".");
TDEquals(tok.floatValue, (CGFloat)0.0);
tok = [t nextToken];
TDEqualObjects(tok, [PKToken EOFToken]);
}
@end
Jump to Line
Something went wrong with that request. Please try again.