Skip to content

Commit 51b2ac0

Browse files
committed
Proper ranges
1 parent b433f54 commit 51b2ac0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Sources/Diff/Diff.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public func diff<T>(_ before: [T], _ after: [T], compare: (T, T) -> Bool) -> (Ra
4141
// Insert
4242
if afterCount != commonStart + commonEnd {
4343
let range = commonStart..<(afterCount - commonEnd)
44-
return (commonStart...commonStart, Array(after[range]))
44+
return (commonStart..<commonStart, Array(after[range]))
4545
}
4646

4747
// Already equal

Tests/Diff/DiffTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Diff
1212
class DiffTests: XCTestCase {
1313
func testInsert() {
1414
let (range, string) = diff("Hello world", "Hello there world")!
15-
XCTAssertEqual(6...6, range)
15+
XCTAssertEqual(6..<6, range)
1616
XCTAssertEqual("there ", string)
1717
}
1818

@@ -34,7 +34,7 @@ class DiffTests: XCTestCase {
3434

3535
func testEmptyBefore() {
3636
let (range, string) = diff("", "Hello world")!
37-
XCTAssertEqual(0...0, range)
37+
XCTAssertEqual(0..<0, range)
3838
XCTAssertEqual("Hello world", string)
3939
}
4040

@@ -46,7 +46,7 @@ class DiffTests: XCTestCase {
4646

4747
func testIntArray() {
4848
let (range, replacement) = diff([1, 2, 3], [1, 2, 3, 4])!
49-
XCTAssertEqual(3...3, range)
49+
XCTAssertEqual(3..<3, range)
5050
XCTAssertEqual([4], replacement)
5151
}
5252

@@ -58,7 +58,7 @@ class DiffTests: XCTestCase {
5858

5959
func testReplaceAppend() {
6060
let (range, string) = diff([1, 2], [1, 3, 4])!
61-
XCTAssertEqual(1...1, range)
61+
XCTAssertEqual(1..<2, range)
6262
XCTAssertEqual([3, 4], string)
6363
}
6464

@@ -67,7 +67,7 @@ class DiffTests: XCTestCase {
6767
let after: [Foo] = [Bar(value: 2)]
6868

6969
let (range, replacement) = diff(before, after, compare: compareFoo)!
70-
XCTAssertEqual(0...0, range)
70+
XCTAssertEqual(0..<1, range)
7171
XCTAssertEqual(0, replacement.count)
7272
}
7373
}

0 commit comments

Comments
 (0)