summaryrefslogtreecommitdiff
path: root/vendor/github.com/onsi/gomega/matchers/be_zero_matcher_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/onsi/gomega/matchers/be_zero_matcher_test.go')
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_zero_matcher_test.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/vendor/github.com/onsi/gomega/matchers/be_zero_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_zero_matcher_test.go
new file mode 100644
index 000000000..c89e10330
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_zero_matcher_test.go
@@ -0,0 +1,40 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("BeZero", func() {
+ It("succeeds for zero values for its type", func() {
+ Expect(nil).Should(BeZero())
+
+ Expect("").Should(BeZero())
+ Expect(" ").ShouldNot(BeZero())
+
+ Expect(0).Should(BeZero())
+ Expect(1).ShouldNot(BeZero())
+
+ Expect(0.0).Should(BeZero())
+ Expect(0.1).ShouldNot(BeZero())
+
+ // Expect([]int{}).Should(BeZero())
+ Expect([]int{1}).ShouldNot(BeZero())
+
+ // Expect(map[string]int{}).Should(BeZero())
+ Expect(map[string]int{"a": 1}).ShouldNot(BeZero())
+
+ Expect(myCustomType{}).Should(BeZero())
+ Expect(myCustomType{s: "a"}).ShouldNot(BeZero())
+ })
+
+ It("builds failure message", func() {
+ actual := BeZero().FailureMessage(123)
+ Expect(actual).To(Equal("Expected\n <int>: 123\nto be zero-valued"))
+ })
+
+ It("builds negated failure message", func() {
+ actual := BeZero().NegatedFailureMessage(123)
+ Expect(actual).To(Equal("Expected\n <int>: 123\nnot to be zero-valued"))
+ })
+})