mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-26 18:18:24 +00:00
Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.36.2 to 1.37.0. - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/gomega/compare/v1.36.2...v1.37.0) --- updated-dependencies: - dependency-name: github.com/onsi/gomega dependency-version: 1.37.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
43 lines
1.3 KiB
Go
43 lines
1.3 KiB
Go
package matchers
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"reflect"
|
|
|
|
"github.com/onsi/gomega/format"
|
|
)
|
|
|
|
type EqualMatcher struct {
|
|
Expected any
|
|
}
|
|
|
|
func (matcher *EqualMatcher) Match(actual any) (success bool, err error) {
|
|
if actual == nil && matcher.Expected == nil {
|
|
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.")
|
|
}
|
|
// Shortcut for byte slices.
|
|
// Comparing long byte slices with reflect.DeepEqual is very slow,
|
|
// so use bytes.Equal if actual and expected are both byte slices.
|
|
if actualByteSlice, ok := actual.([]byte); ok {
|
|
if expectedByteSlice, ok := matcher.Expected.([]byte); ok {
|
|
return bytes.Equal(actualByteSlice, expectedByteSlice), nil
|
|
}
|
|
}
|
|
return reflect.DeepEqual(actual, matcher.Expected), nil
|
|
}
|
|
|
|
func (matcher *EqualMatcher) FailureMessage(actual any) (message string) {
|
|
actualString, actualOK := actual.(string)
|
|
expectedString, expectedOK := matcher.Expected.(string)
|
|
if actualOK && expectedOK {
|
|
return format.MessageWithDiff(actualString, "to equal", expectedString)
|
|
}
|
|
|
|
return format.Message(actual, "to equal", matcher.Expected)
|
|
}
|
|
|
|
func (matcher *EqualMatcher) NegatedFailureMessage(actual any) (message string) {
|
|
return format.Message(actual, "not to equal", matcher.Expected)
|
|
}
|