deepequal_test.go 698 B

123456789101112131415161718192021222324252627282930
  1. // Copyright (c) 2014 Arista Networks, Inc.
  2. // Use of this source code is governed by the Apache License 2.0
  3. // that can be found in the COPYING file.
  4. package test
  5. import "testing"
  6. type comparableStruct struct {
  7. a uint32
  8. t *testing.T
  9. }
  10. func (c comparableStruct) Equal(v interface{}) bool {
  11. other, ok := v.(comparableStruct)
  12. // Deliberately ignore t.
  13. return ok && c.a == other.a
  14. }
  15. func TestDeepEqual(t *testing.T) {
  16. testcases := getDeepEqualTests(t)
  17. for _, test := range testcases {
  18. equal := len(test.diff) == 0
  19. if actual := DeepEqual(test.a, test.b); actual != equal {
  20. t.Errorf("DeepEqual returned %t but we wanted %t for %#v == %#v",
  21. actual, equal, test.a, test.b)
  22. }
  23. }
  24. }