forked from SwiftGit2/SwiftGit2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOIDSpec.swift
72 lines (62 loc) · 1.91 KB
/
OIDSpec.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// OIDSpec.swift
// SwiftGit2
//
// Created by Matt Diephouse on 11/17/14.
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
//
import SwiftGit2
import Nimble
import Quick
class OIDSpec: QuickSpec {
override func spec() {
describe("OID(string:)") {
it("should be nil if string is too short") {
expect(OID(string: "123456789012345678901234567890123456789")).to(beNil())
}
it("should be nil if string is too long") {
expect(OID(string: "12345678901234567890123456789012345678901")).to(beNil())
}
it("should not be nil if string is just right") {
expect(OID(string: "1234567890123456789012345678ABCDEFabcdef")).notTo(beNil())
}
it("should be nil with non-hex characters") {
expect(OID(string: "123456789012345678901234567890123456789j")).to(beNil())
}
}
describe("OID(oid)") {
it("should equal an OID with the same git_oid") {
let oid = OID(string: "1234567890123456789012345678901234567890")!
expect(OID(oid.oid)).to(equal(oid))
}
}
describe("OID.description") {
it("should return the SHA") {
let SHA = "1234567890123456789012345678901234567890"
let oid = OID(string: SHA)!
expect(oid.description).to(equal(SHA))
}
}
describe("==(OID, OID)") {
it("should be equal when identical") {
let SHA = "1234567890123456789012345678901234567890"
let oid1 = OID(string: SHA)!
let oid2 = OID(string: SHA)!
expect(oid1).to(equal(oid2))
}
it("should be not equal when different") {
let oid1 = OID(string: "1234567890123456789012345678901234567890")!
let oid2 = OID(string: "0000000000000000000000000000000000000000")!
expect(oid1).notTo(equal(oid2))
}
}
describe("OID.hashValue") {
it("should be equal when OIDs are equal") {
let SHA = "1234567890123456789012345678901234567890"
let oid1 = OID(string: SHA)!
let oid2 = OID(string: SHA)!
expect(oid1.hashValue).to(equal(oid2.hashValue))
}
}
}
}