|
15 | 15 | import SwiftXCTest |
16 | 16 | #endif |
17 | 17 |
|
18 | | -class TestNSData: XCTestCase { |
| 18 | +class TestNSData: LoopbackServerTest { |
19 | 19 |
|
20 | 20 | class AllOnesImmutableData : NSData { |
21 | 21 | private var _length : Int |
@@ -201,6 +201,7 @@ class TestNSData: XCTestCase { |
201 | 201 | ("test_openingNonExistentFile", test_openingNonExistentFile), |
202 | 202 | ("test_contentsOfFile", test_contentsOfFile), |
203 | 203 | ("test_contentsOfZeroFile", test_contentsOfZeroFile), |
| 204 | + ("test_contentsOfURL", test_contentsOfURL), |
204 | 205 | ("test_basicReadWrite", test_basicReadWrite), |
205 | 206 | ("test_bufferSizeCalculation", test_bufferSizeCalculation), |
206 | 207 | ("test_dataHash", test_dataHash), |
@@ -1473,6 +1474,16 @@ extension TestNSData { |
1473 | 1474 | #endif |
1474 | 1475 | } |
1475 | 1476 |
|
| 1477 | + func test_contentsOfURL() { |
| 1478 | + let urlString = "http://127.0.0.1:\(TestURLSession.serverPort)/country.txt" |
| 1479 | + let url = URL(string: urlString)! |
| 1480 | + let contents = NSData(contentsOf: url) |
| 1481 | + XCTAssertNotNil(contents) |
| 1482 | + if let contents = contents { |
| 1483 | + XCTAssertTrue(contents.length > 0) |
| 1484 | + } |
| 1485 | + } |
| 1486 | + |
1476 | 1487 | func test_basicReadWrite() { |
1477 | 1488 | let url = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true).appendingPathComponent("testfile") |
1478 | 1489 | let count = 1 << 24 |
|
0 commit comments