Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
kardolus
GitHub Repository: kardolus/chatgpt-cli
Path: blob/main/vendor/github.com/onsi/gomega/matchers/be_identical_to.go
2880 views
1
// untested sections: 2
2
3
package matchers
4
5
import (
6
"fmt"
7
"runtime"
8
9
"github.com/onsi/gomega/format"
10
)
11
12
type BeIdenticalToMatcher struct {
13
Expected any
14
}
15
16
func (matcher *BeIdenticalToMatcher) Match(actual any) (success bool, matchErr error) {
17
if actual == nil && matcher.Expected == nil {
18
return false, fmt.Errorf("Refusing to compare <nil> to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
19
}
20
21
defer func() {
22
if r := recover(); r != nil {
23
if _, ok := r.(runtime.Error); ok {
24
success = false
25
matchErr = nil
26
}
27
}
28
}()
29
30
return actual == matcher.Expected, nil
31
}
32
33
func (matcher *BeIdenticalToMatcher) FailureMessage(actual any) string {
34
return format.Message(actual, "to be identical to", matcher.Expected)
35
}
36
37
func (matcher *BeIdenticalToMatcher) NegatedFailureMessage(actual any) string {
38
return format.Message(actual, "not to be identical to", matcher.Expected)
39
}
40
41