PageRenderTime 21ms CodeModel.GetById 13ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Tests/Objective-J/CFURLTest.j

http://github.com/cacaodev/cappuccino
Unknown | 99 lines | 90 code | 9 blank | 0 comment | 0 complexity | 42ff5933f066994e8bd7811569cab6c1 MD5 | raw file
 1
 2@implementation CFURLTest : OJTestCase
 3{
 4}
 5
 6- (void)testRelativeURLs
 7{
 8    var URLStrings =
 9    {
10        "g:h"           : "g:h",
11        "g"             : "http://a/b/c/g",
12        "./g"           : "http://a/b/c/g",
13        "g/"            : "http://a/b/c/g/",
14        "/g"            : "http://a/g",
15        //"//g"           : "http://g",
16        "?y"            : "http://a/b/c/?y",
17        "g?y"           : "http://a/b/c/g?y",
18        //"#s"            : "(current document)#s",
19        "g#s"           : "http://a/b/c/g#s",
20        "g?y#s"         : "http://a/b/c/g?y#s",
21        ";x"            : "http://a/b/c/;x",
22        "g;x"           : "http://a/b/c/g;x",
23        "g;x?y#s"       : "http://a/b/c/g;x?y#s",
24        "."             : "http://a/b/c/",
25        "./"            : "http://a/b/c/",
26        ".."            : "http://a/b/",
27        "../"           : "http://a/b/",
28        "../g"          : "http://a/b/g",
29        "../.."         : "http://a/",
30        "../../"        : "http://a/",
31        "../../g"       : "http://a/g",
32        "../../../g"    : "http://a/g",//"http://a/../g",
33        "../../../../g" : "http://a/g",//"http://a/../../g",
34        "/./g"          : "http://a/g",//"http://a/./g",
35        "/../g"         : "http://a/g",//"http://a/../g",
36        "g."            : "http://a/b/c/g.",
37        ".g"            : "http://a/b/c/.g",
38        "g.."           : "http://a/b/c/g..",
39        "..g"           : "http://a/b/c/..g",
40        "./../g"        :  "http://a/b/g",
41        "./g/."         :  "http://a/b/c/g/",
42        "g/./h"         :  "http://a/b/c/g/h",
43        "g/../h"        :  "http://a/b/c/h",
44        "g;x=1/./y"     :  "http://a/b/c/g;x=1/y",
45        "g;x=1/../y"    :  "http://a/b/c/y",
46        "g?y/./x"       :  "http://a/b/c/g?y/./x",
47        "g?y/../x"      :  "http://a/b/c/g?y/../x",
48        "g#s/./x"       :  "http://a/b/c/g#s/./x",
49        "g#s/../x"      :  "http://a/b/c/g#s/../x"
50    };
51
52    var URLString,
53        baseURL = new CFURL("http://a/b/c/d;p?q");
54
55    for (URLString in URLStrings)
56        if (URLStrings.hasOwnProperty(URLString))
57        {
58//            print(URLStrings[URLString] + " " + new CFURL(URLString, baseURL).absoluteString());
59            [self assert:URLStrings[URLString] equals:new CFURL(URLString, baseURL).absoluteString()];
60        }
61}
62
63- (void)testPeriods
64{
65    var URLStrings =
66    {
67        "."             : "./",
68        "./"            : "./",
69        ".//"           : "./",
70        "/."            : "/",
71        "/./"           : "/",
72        "/.//"          : "/",
73        "./a/"          : "a/",
74        "./a"           : "a",
75        ".."            : "../",
76        "../"           : "../",
77        "..//"          : "../",
78        "/.."           : "/",
79        "/../"          : "/",
80        "/..//"         : "/",
81        "../a/"         : "../a/",
82        "../a"          : "../a"
83    };
84
85    var URLString;
86
87    for (URLString in URLStrings)
88        if (URLStrings.hasOwnProperty(URLString))
89            [self assert:new CFURL(URLString).absoluteString() equals:URLStrings[URLString]];
90}
91
92- (void)testDoubleSlash
93{
94    [self assert:"//a" equals:new CFURL("//a").absoluteString()];
95    [self assert:"ftp://a" equals:new CFURL("//a", new CFURL("ftp://example.com/b")).absoluteString()];
96    [self assert:"ftp://example.com/a" equals:new CFURL("/a", new CFURL("ftp://example.com/b")).absoluteString()];
97}
98
99@end