added support for string type
[govpp.git] / vendor / github.com / onsi / gomega / matchers / be_empty_matcher_test.go
1 package matchers_test
2
3 import (
4         . "github.com/onsi/ginkgo"
5         . "github.com/onsi/gomega"
6         . "github.com/onsi/gomega/matchers"
7 )
8
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())
14
15                         Ω([0]int{}).Should(BeEmpty())
16                         Ω([1]int{1}).ShouldNot(BeEmpty())
17
18                         Ω([]int{}).Should(BeEmpty())
19                         Ω([]int{1}).ShouldNot(BeEmpty())
20
21                         Ω(map[string]int{}).Should(BeEmpty())
22                         Ω(map[string]int{"a": 1}).ShouldNot(BeEmpty())
23
24                         c := make(chan bool, 1)
25                         Ω(c).Should(BeEmpty())
26                         c <- true
27                         Ω(c).ShouldNot(BeEmpty())
28                 })
29         })
30
31         Context("when passed a correctly typed nil", func() {
32                 It("should be true", func() {
33                         var nilSlice []int
34                         Ω(nilSlice).Should(BeEmpty())
35
36                         var nilMap map[int]string
37                         Ω(nilMap).Should(BeEmpty())
38                 })
39         })
40
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())
46
47                         success, err = (&BeEmptyMatcher{}).Match(nil)
48                         Ω(success).Should(BeFalse())
49                         Ω(err).Should(HaveOccurred())
50                 })
51         })
52 })