@@ -523,7 +523,9 @@ class TestURLComponents : XCTestCase {
523
523
( " test_port " , test_portSetter) ,
524
524
( " test_url " , test_url) ,
525
525
( " test_copy " , test_copy) ,
526
- ( " test_createURLWithComponents " , test_createURLWithComponents)
526
+ ( " test_createURLWithComponents " , test_createURLWithComponents) ,
527
+ ( " test_path " , test_path) ,
528
+ ( " test_percentEncodedPath " , test_percentEncodedPath) ,
527
529
]
528
530
}
529
531
@@ -617,4 +619,43 @@ class TestURLComponents : XCTestCase {
617
619
XCTAssertEqual ( urlComponents. queryItems? . count, 4 )
618
620
}
619
621
622
+ func test_path( ) {
623
+ let c1 = URLComponents ( )
624
+ XCTAssertEqual ( c1. path, " " )
625
+
626
+ let c2 = URLComponents ( string: " http://swift.org " )
627
+ XCTAssertEqual ( c2? . path, " " )
628
+
629
+ let c3 = URLComponents ( string: " http://swift.org/ " )
630
+ XCTAssertEqual ( c3? . path, " / " )
631
+
632
+ let c4 = URLComponents ( string: " http://swift.org/foo/bar " )
633
+ XCTAssertEqual ( c4? . path, " /foo/bar " )
634
+
635
+ let c5 = URLComponents ( string: " http://swift.org:80/foo/bar " )
636
+ XCTAssertEqual ( c5? . path, " /foo/bar " )
637
+
638
+ let c6 = URLComponents ( string: " http://swift.org:80/foo/b%20r " )
639
+ XCTAssertEqual ( c6? . path, " /foo/b r " )
640
+ }
641
+
642
+ func test_percentEncodedPath( ) {
643
+ let c1 = URLComponents ( )
644
+ XCTAssertEqual ( c1. percentEncodedPath, " " )
645
+
646
+ let c2 = URLComponents ( string: " http://swift.org " )
647
+ XCTAssertEqual ( c2? . percentEncodedPath, " " )
648
+
649
+ let c3 = URLComponents ( string: " http://swift.org/ " )
650
+ XCTAssertEqual ( c3? . percentEncodedPath, " / " )
651
+
652
+ let c4 = URLComponents ( string: " http://swift.org/foo/bar " )
653
+ XCTAssertEqual ( c4? . percentEncodedPath, " /foo/bar " )
654
+
655
+ let c5 = URLComponents ( string: " http://swift.org:80/foo/bar " )
656
+ XCTAssertEqual ( c5? . percentEncodedPath, " /foo/bar " )
657
+
658
+ let c6 = URLComponents ( string: " http://swift.org:80/foo/b%20r " )
659
+ XCTAssertEqual ( c6? . percentEncodedPath, " /foo/b%20r " )
660
+ }
620
661
}
0 commit comments