initial commit
[govpp.git] / vendor / github.com / onsi / gomega / matchers / be_equivalent_to_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("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)
13
14                         Ω(success).Should(BeFalse())
15                         Ω(err).Should(HaveOccurred())
16                 })
17         })
18
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))
24                 })
25         })
26
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")))
33                 })
34         })
35
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))
41
42                         Ω(5).ShouldNot(BeEquivalentTo("5"))
43                         Ω(5).ShouldNot(BeEquivalentTo(3))
44
45                         //Here be dragons!
46                         Ω(5.1).Should(BeEquivalentTo(5))
47                         Ω(5).ShouldNot(BeEquivalentTo(5.1))
48                 })
49         })
50 })