4 . "github.com/onsi/ginkgo"
5 . "github.com/onsi/gomega"
6 . "github.com/onsi/gomega/matchers"
9 var _ = Describe("BeEmpty", func() {
10 Context("when passed a supported type", func() {
11 It("should do the right thing", func() {
12 Ω("").Should(BeEmpty())
13 Ω(" ").ShouldNot(BeEmpty())
15 Ω([0]int{}).Should(BeEmpty())
16 Ω([1]int{1}).ShouldNot(BeEmpty())
18 Ω([]int{}).Should(BeEmpty())
19 Ω([]int{1}).ShouldNot(BeEmpty())
21 Ω(map[string]int{}).Should(BeEmpty())
22 Ω(map[string]int{"a": 1}).ShouldNot(BeEmpty())
24 c := make(chan bool, 1)
25 Ω(c).Should(BeEmpty())
27 Ω(c).ShouldNot(BeEmpty())
31 Context("when passed a correctly typed nil", func() {
32 It("should be true", func() {
34 Ω(nilSlice).Should(BeEmpty())
36 var nilMap map[int]string
37 Ω(nilMap).Should(BeEmpty())
41 Context("when passed an unsupported type", func() {
42 It("should error", func() {
43 success, err := (&BeEmptyMatcher{}).Match(0)
44 Ω(success).Should(BeFalse())
45 Ω(err).Should(HaveOccurred())
47 success, err = (&BeEmptyMatcher{}).Match(nil)
48 Ω(success).Should(BeFalse())
49 Ω(err).Should(HaveOccurred())