Skip to content

Commit 090eb4b

Browse files
committed
Add tests for first and last range w/ empty data searched
1 parent 4ba3605 commit 090eb4b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Tests/Foundation/Tests/TestNSData.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ class TestNSData: LoopbackServerTest {
212212
("testCopyBytes", testCopyBytes),
213213
("testCustomDeallocator", testCustomDeallocator),
214214
("testDataInSet", testDataInSet),
215+
("testFirstRangeEmptyData", testFirstRangeEmptyData),
216+
("testLastRangeEmptyData", testLastRangeEmptyData),
215217
("testEquality", testEquality),
216218
("testGenericAlgorithms", testGenericAlgorithms),
217219
("testInitializationWithArray", testInitializationWithArray),
@@ -1194,6 +1196,16 @@ extension TestNSData {
11941196
XCTAssertEqual(s.count, 2, "Expected only two entries in the Set")
11951197
}
11961198

1199+
func testFirstRangeEmptyData() {
1200+
let d = Data([1, 2, 3])
1201+
XCTAssertNil(d.firstRange(of: Data()))
1202+
}
1203+
1204+
func testLastRangeEmptyData() {
1205+
let d = Data([1, 2, 3])
1206+
XCTAssertNil(d.lastRange(of: Data()))
1207+
}
1208+
11971209
func testReplaceSubrange() {
11981210
var hello = dataFrom("Hello")
11991211
let world = dataFrom("World")

0 commit comments

Comments
 (0)