github.com/aristanetworks/goarista@v0.0.0-20240514173732-cca2755bbd44/test/deepequal_test.go (about) 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 5 package test 6 7 import "testing" 8 9 type comparableStruct struct { 10 a uint32 11 t *testing.T 12 } 13 14 func (c comparableStruct) Equal(v interface{}) bool { 15 other, ok := v.(comparableStruct) 16 // Deliberately ignore t. 17 return ok && c.a == other.a 18 } 19 20 func TestDeepEqual(t *testing.T) { 21 testcases := getDeepEqualTests(t) 22 for _, test := range testcases { 23 equal := len(test.diff) == 0 24 if actual := DeepEqual(test.a, test.b); actual != equal { 25 t.Errorf("DeepEqual returned %t but we wanted %t for %#v == %#v", 26 actual, equal, test.a, test.b) 27 } 28 } 29 }