4 . "github.com/onsi/ginkgo"
5 . "github.com/onsi/gomega"
6 . "github.com/onsi/gomega/matchers"
9 var _ = Describe("BeEquivalentTo", func() {
10 Context("when asserting that nil is equivalent to nil", func() {
11 It("should error", func() {
12 success, err := (&BeEquivalentToMatcher{Expected: nil}).Match(nil)
14 Ω(success).Should(BeFalse())
15 Ω(err).Should(HaveOccurred())
19 Context("When asserting on nil", func() {
20 It("should do the right thing", func() {
21 Ω("foo").ShouldNot(BeEquivalentTo(nil))
22 Ω(nil).ShouldNot(BeEquivalentTo(3))
23 Ω([]int{1, 2}).ShouldNot(BeEquivalentTo(nil))
27 Context("When asserting on type aliases", func() {
28 It("should the right thing", func() {
29 Ω(StringAlias("foo")).Should(BeEquivalentTo("foo"))
30 Ω("foo").Should(BeEquivalentTo(StringAlias("foo")))
31 Ω(StringAlias("foo")).ShouldNot(BeEquivalentTo("bar"))
32 Ω("foo").ShouldNot(BeEquivalentTo(StringAlias("bar")))
36 Context("When asserting on numbers", func() {
37 It("should convert actual to expected and do the right thing", func() {
38 Ω(5).Should(BeEquivalentTo(5))
39 Ω(5.0).Should(BeEquivalentTo(5.0))
40 Ω(5).Should(BeEquivalentTo(5.0))
42 Ω(5).ShouldNot(BeEquivalentTo("5"))
43 Ω(5).ShouldNot(BeEquivalentTo(3))
46 Ω(5.1).Should(BeEquivalentTo(5))
47 Ω(5).ShouldNot(BeEquivalentTo(5.1))