SwiftGit2/SwiftGit2Tests/OIDSpec.swift
2014-11-19 09:07:24 -05:00

67 lines
1.7 KiB
Swift

//
// OIDSpec.swift
// SwiftGit2
//
// Created by Matt Diephouse on 11/17/14.
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
//
import LlamaKit
import SwiftGit2
import Nimble
import Quick
class OIDSpec: QuickSpec {
override func spec() {
describe("init(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: "1234567890123456789012345678901234567890")).notTo(beNil())
}
it("should be nil with non-hex characters") {
expect(OID(string: "123456789012345678901234567890123456789j")).to(beNil())
}
}
describe("description") {
it("should return the SHA") {
let SHA = "1234567890123456789012345678901234567890"
let oid = OID(string: SHA)!
expect(oid.description).to(equal(SHA))
}
}
describe("==") {
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("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))
}
}
}
}