Skip to content

Commit

Permalink
Merge pull request ra1028#15 from ra1028/v0.5.2
Browse files Browse the repository at this point in the history
V0.5.2
  • Loading branch information
ra1028 authored Aug 27, 2018
2 parents 42a7d4c + f4d92b5 commit 71acd7a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DifferenceKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'DifferenceKit'
spec.version = '0.5.1'
spec.version = '0.5.2'
spec.author = { 'ra1028' => '[email protected]' }
spec.homepage = 'https://github.com/ra1028/DifferenceKit'
spec.documentation_url = 'https://ra1028.github.io/DifferenceKit'
Expand Down
3 changes: 1 addition & 2 deletions Sources/Algorithm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,7 @@ private struct TableKey<T: Hashable>: Hashable {

static func == (lhs: TableKey, rhs: TableKey) -> Bool {
return lhs.hashValue == rhs.hashValue
|| lhs.pointer.distance(to: rhs.pointer) == 0
|| lhs.pointer.pointee == rhs.pointer.pointee
&& (lhs.pointer.distance(to: rhs.pointer) == 0 || lhs.pointer.pointee == rhs.pointer.pointee)
}
}

Expand Down
36 changes: 36 additions & 0 deletions Tests/AlgorithmTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,42 @@ extension AlgorithmTestCase {
]
)
}

func testSameHashValue() {
struct A: Hashable, Differentiable {
let hashValue = 0
let actualValue: Int

init(_ actualValue: Int) {
self.actualValue = actualValue
}

func isContentEqual(to source: A) -> Bool {
return actualValue == source.actualValue
}
}

let section = 0

let source = [A(0), A(1)]
let target = [A(0), A(2)]

XCTAssertExactDifferences(
source: source,
target: target,
section: section,
expected: [
Changeset(
data: [A(0)],
elementDeleted: [ElementPath(element: 1, section: section)]
),
Changeset(
data: target,
elementInserted: [ElementPath(element: 1, section: section)]
)
]
)
}
}

/// Test algorithm for sectioned collection.
Expand Down

0 comments on commit 71acd7a

Please sign in to comment.