mirror of
https://github.com/gosticks/SwiftGit2.git
synced 2025-10-16 11:55:34 +00:00
Make TagReference Hashable
This commit is contained in:
parent
fc641cbb94
commit
a0f76f6c26
@ -169,4 +169,14 @@ public enum TagReference: ReferenceType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension TagReference: Hashable {
|
||||||
|
public var hashValue: Int {
|
||||||
|
return longName.hashValue ^ oid.hashValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func == (lhs: TagReference, rhs: TagReference) -> Bool {
|
||||||
|
return lhs.longName == rhs.longName
|
||||||
|
&& lhs.oid == rhs.oid
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -130,5 +130,30 @@ class TagReferenceSpec: QuickSpec {
|
|||||||
expect(tag).to(beNil())
|
expect(tag).to(beNil())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
describe("==") {
|
||||||
|
it("should be true with equal tag references") {
|
||||||
|
let repo = Fixtures.simpleRepository
|
||||||
|
let tag1 = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! }
|
||||||
|
let tag2 = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! }
|
||||||
|
expect(tag1).to(equal(tag2))
|
||||||
|
}
|
||||||
|
|
||||||
|
it("should be false with unequal tag references") {
|
||||||
|
let repo = Fixtures.simpleRepository
|
||||||
|
let tag1 = from_git_reference(repo, "refs/tags/tag-1") { TagReference($0)! }
|
||||||
|
let tag2 = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! }
|
||||||
|
expect(tag1).notTo(equal(tag2))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("hashValue") {
|
||||||
|
it("should be equal with equal references") {
|
||||||
|
let repo = Fixtures.simpleRepository
|
||||||
|
let tag1 = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! }
|
||||||
|
let tag2 = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! }
|
||||||
|
expect(tag1.hashValue).to(equal(tag2.hashValue))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user