initial commit
[govpp.git] / vendor / github.com / onsi / gomega / matchers / be_identical_to_test.go
1 package matchers_test
2
3 import (
4         "errors"
5
6         . "github.com/onsi/ginkgo"
7         . "github.com/onsi/gomega"
8         . "github.com/onsi/gomega/matchers"
9 )
10
11 var _ = Describe("BeIdenticalTo", func() {
12         Context("when asserting that nil equals nil", func() {
13                 It("should error", func() {
14                         success, err := (&BeIdenticalToMatcher{Expected: nil}).Match(nil)
15
16                         Ω(success).Should(BeFalse())
17                         Ω(err).Should(HaveOccurred())
18                 })
19         })
20
21         It("should treat the same pointer to a struct as identical", func() {
22                 mySpecialStruct := myCustomType{}
23                 Ω(&mySpecialStruct).Should(BeIdenticalTo(&mySpecialStruct))
24                 Ω(&myCustomType{}).ShouldNot(BeIdenticalTo(&mySpecialStruct))
25         })
26
27         It("should be strict about types", func() {
28                 Ω(5).ShouldNot(BeIdenticalTo("5"))
29                 Ω(5).ShouldNot(BeIdenticalTo(5.0))
30                 Ω(5).ShouldNot(BeIdenticalTo(3))
31         })
32
33         It("should treat primtives as identical", func() {
34                 Ω("5").Should(BeIdenticalTo("5"))
35                 Ω("5").ShouldNot(BeIdenticalTo("55"))
36
37                 Ω(5.55).Should(BeIdenticalTo(5.55))
38                 Ω(5.55).ShouldNot(BeIdenticalTo(6.66))
39
40                 Ω(5).Should(BeIdenticalTo(5))
41                 Ω(5).ShouldNot(BeIdenticalTo(55))
42         })
43
44         It("should treat the same pointers to a slice as identical", func() {
45                 mySlice := []int{1, 2}
46                 Ω(&mySlice).Should(BeIdenticalTo(&mySlice))
47                 Ω(&mySlice).ShouldNot(BeIdenticalTo(&[]int{1, 2}))
48         })
49
50         It("should treat the same pointers to a map as identical", func() {
51                 myMap := map[string]string{"a": "b", "c": "d"}
52                 Ω(&myMap).Should(BeIdenticalTo(&myMap))
53                 Ω(myMap).ShouldNot(BeIdenticalTo(map[string]string{"a": "b", "c": "d"}))
54         })
55
56         It("should treat the same pointers to an error as identical", func() {
57                 myError := errors.New("foo")
58                 Ω(&myError).Should(BeIdenticalTo(&myError))
59                 Ω(errors.New("foo")).ShouldNot(BeIdenticalTo(errors.New("bar")))
60         })
61 })