4 . "github.com/onsi/ginkgo"
5 . "github.com/onsi/gomega"
6 . "github.com/onsi/gomega/matchers"
9 var _ = Describe("HaveCap", func() {
10 Context("when passed a supported type", func() {
11 It("should do the right thing", func() {
12 Ω([0]int{}).Should(HaveCap(0))
13 Ω([2]int{1}).Should(HaveCap(2))
15 Ω([]int{}).Should(HaveCap(0))
16 Ω([]int{1, 2, 3, 4, 5}[:2]).Should(HaveCap(5))
17 Ω(make([]int, 0, 5)).Should(HaveCap(5))
19 c := make(chan bool, 3)
20 Ω(c).Should(HaveCap(3))
23 Ω(c).Should(HaveCap(3))
25 Ω(make(chan bool)).Should(HaveCap(0))
29 Context("when passed a correctly typed nil", func() {
30 It("should operate succesfully on the passed in value", func() {
32 Ω(nilSlice).Should(HaveCap(0))
35 Ω(nilChan).Should(HaveCap(0))
39 Context("when passed an unsupported type", func() {
40 It("should error", func() {
41 success, err := (&HaveCapMatcher{Count: 0}).Match(0)
42 Ω(success).Should(BeFalse())
43 Ω(err).Should(HaveOccurred())
45 success, err = (&HaveCapMatcher{Count: 0}).Match(nil)
46 Ω(success).Should(BeFalse())
47 Ω(err).Should(HaveOccurred())