New test data just found a bug. Fixed it.
Signed-off-by: Adam Rocska <adam.rocska@adams.solutions>
This commit is contained in:
parent
4a854026ec
commit
c1c9c55d4f
|
@ -6,7 +6,7 @@ extension Data {
|
|||
let patternLength = data.count
|
||||
precondition(patternLength > 0, "Pattern can't be empty.")
|
||||
precondition(self.count >= patternLength, "Pattern can't be >= than the Data to search in.")
|
||||
precondition(data.indices.contains(from), "Index from which to start the lookup must be contained in the Data.")
|
||||
precondition(self.indices.contains(from), "Index from which to start the lookup must be contained in the Data.")
|
||||
|
||||
var skipTable = [UInt8: Int]()
|
||||
for (i, byte) in data.enumerated() {
|
||||
|
|
|
@ -20,6 +20,16 @@ class IndexOfData: XCTestCase {
|
|||
}
|
||||
|
||||
func testIndex_ofData_fromIndex() {
|
||||
XCTAssertEqual(12, "Hello World Hello World".asciiData.index(of: "Hello World".asciiData, from: 3))
|
||||
XCTAssertEqual(6, "Hello World".asciiData.index(of: "World".asciiData, from: 3))
|
||||
XCTAssertNil("Hello world".asciiData.index(of: "World".asciiData, from: 3))
|
||||
XCTAssertEqual(6, "Hello World SOME World".asciiData.index(of: "World".asciiData, from: 2))
|
||||
XCTAssertEqual(17, "Hello world SOME World".asciiData.index(of: "World".asciiData, from: 4))
|
||||
XCTAssertNil("Hello World".asciiData.index(of: "Hello".asciiData, from: 3))
|
||||
XCTAssertNil("hello World".asciiData.index(of: "hello".asciiData, from: 3))
|
||||
XCTAssertNil("hello world".asciiData.index(of: "Hello".asciiData, from: 3))
|
||||
XCTAssertNil("hello World SOME World".asciiData.index(of: "Hello".asciiData, from: 3))
|
||||
XCTAssertNil("hello world SOME World".asciiData.index(of: "Hello".asciiData, from: 3))
|
||||
XCTAssertEqual(6, "Hello World Hello World".asciiData.index(of: "World".asciiData, from: 6))
|
||||
XCTAssertEqual(18, "Hello World Hello World".asciiData.index(of: "World".asciiData, from: 7))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue