Skip to content

Commit ca6eca0

Browse files
committed
DarwinCompatibility: TestStream.seek(to:) is internal API
1 parent 953257c commit ca6eca0

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

TestFoundation/TestStream.swift

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
88
//
99

10-
#if (os(Linux) || os(Android))
11-
@testable import Foundation
12-
#else
13-
@testable import SwiftFoundation
10+
#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
11+
#if canImport(SwiftFoundation)
12+
@testable import SwiftFoundation
13+
#else
14+
@testable import Foundation
15+
#endif
1416
#endif
1517

1618

@@ -33,20 +35,24 @@ private extension Data {
3335

3436
class TestStream : XCTestCase {
3537
static var allTests: [(String, (TestStream) -> () throws -> Void)] {
36-
return [
38+
var tests: [(String, (TestStream) -> () throws -> Void)] = [
3739
("test_InputStreamWithData", test_InputStreamWithData),
3840
("test_InputStreamWithUrl", test_InputStreamWithUrl),
3941
("test_InputStreamWithFile", test_InputStreamWithFile),
4042
("test_InputStreamHasBytesAvailable", test_InputStreamHasBytesAvailable),
4143
("test_InputStreamInvalidPath", test_InputStreamInvalidPath),
42-
("test_InputStreamSeekToPosition", test_InputStreamSeekToPosition),
4344
("test_outputStreamCreationToFile", test_outputStreamCreationToFile),
4445
("test_outputStreamCreationToBuffer", test_outputStreamCreationToBuffer),
4546
("test_outputStreamCreationWithUrl", test_outputStreamCreationWithUrl),
4647
("test_outputStreamCreationToMemory", test_outputStreamCreationToMemory),
4748
("test_outputStreamHasSpaceAvailable", test_outputStreamHasSpaceAvailable),
4849
("test_ouputStreamWithInvalidPath", test_ouputStreamWithInvalidPath),
4950
]
51+
52+
#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
53+
tests.append(("test_InputStreamSeekToPosition", test_InputStreamSeekToPosition))
54+
#endif
55+
return tests
5056
}
5157

5258
func test_InputStreamWithData(){
@@ -140,7 +146,8 @@ class TestStream : XCTestCase {
140146
fileStream.open()
141147
XCTAssertEqual(.error, fileStream.streamStatus)
142148
}
143-
149+
150+
#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT // Stream.seek(to:) is an internal API method
144151
func test_InputStreamSeekToPosition() {
145152
let str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras congue laoreet facilisis. Sed porta tristique orci. Fusce ut nisl dignissim, tempor tortor id, molestie neque. Nam non tincidunt mi. Integer ac diam quis leo aliquam congue et non magna. In porta mauris suscipit erat pulvinar, sed fringilla quam ornare. Nulla vulputate et ligula vitae sollicitudin. Nulla vel vehicula risus. Quisque eu urna ullamcorper, tincidunt ante vitae, aliquet sem. Suspendisse nec turpis placerat, porttitor ex vel, tristique orci. Maecenas pretium, augue non elementum imperdiet, diam ex vestibulum tortor, non ultrices ante enim iaculis ex. Fusce ut nisl dignissim, tempor tortor id, molestie neque. Nam non tincidunt mi. Integer ac diam quis leo aliquam congue et non magna. In porta mauris suscipit erat pulvinar, sed fringilla quam ornare. Nulla vulputate et ligula vitae sollicitudin. Nulla vel vehicula risus. Quisque eu urna ullamcorper, tincidunt ante vitae, aliquet sem. Suspendisse nec turpis placerat, porttitor ex vel, tristique orci. Maecenas pretium, augue non elementum imperdiet, diam ex vestibulum tortor, non ultrices ante enim iaculis ex.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras congue laoreet facilisis. Sed porta tristique orci. Fusce ut nisl dignissim, tempor tortor id, molestie neque. Nam non tincidunt mi. Integer ac diam quis leo aliquam congue et non magna. In porta mauris suscipit erat pulvinar, sed fringilla quam ornare. Nulla vulputate et ligula vitae sollicitudin. Nulla vel vehicula risus. Quisque eu urna ullamcorper, tincidunt ante vitae, aliquet sem. Suspendisse nec turpis placerat, porttitor ex vel."
146153
XCTAssert(str.count > 1024) // str.count must be bigger than buffersize inside InputStream.seek func.
@@ -184,6 +191,7 @@ class TestStream : XCTestCase {
184191
XCTFail()
185192
}
186193
}
194+
#endif
187195

188196
func test_outputStreamCreationToFile() {
189197
guard let filePath = createTestFile("TestFileOut.txt", _contents: Data(capacity: 256)) else {

0 commit comments

Comments
 (0)