1 // Copyright 2017, The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE.md file.
10 pb "github.com/google/go-cmp/cmp/internal/testprotos"
13 // This is an sanitized example of equality from a real use-case.
14 // The original equality function was as follows:
16 func equalDirt(x, y *Dirt) bool {
17 if !reflect.DeepEqual(x.table, y.table) ||
18 !reflect.DeepEqual(x.ts, y.ts) ||
19 x.Discord != y.Discord ||
20 !pb.Equal(&x.Proto, &y.Proto) ||
21 len(x.wizard) != len(y.wizard) ||
22 len(x.sadistic) != len(y.sadistic) ||
23 x.lastTime != y.lastTime {
26 for k, vx := range x.wizard {
28 if !ok || !pb.Equal(vx, vy) {
32 for k, vx := range x.sadistic {
33 vy, ok := y.sadistic[k]
34 if !ok || !pb.Equal(vx, vy) {
42 type FakeMutex struct {
48 table Table // Always concrete type of MockTable
52 wizard map[string]*pb.Wizard
53 sadistic map[string]*pb.Sadistic
62 func (d *Dirt) SetTable(t Table) { d.table = t }
63 func (d *Dirt) SetTimestamp(t Timestamp) { d.ts = t }
64 func (d *Dirt) SetWizard(m map[string]*pb.Wizard) { d.wizard = m }
65 func (d *Dirt) SetSadistic(m map[string]*pb.Sadistic) { d.sadistic = m }
66 func (d *Dirt) SetLastTime(t int64) { d.lastTime = t }
68 type Table interface {
74 type MockTable struct {
78 func CreateMockTable(s []string) *MockTable { return &MockTable{s} }
79 func (mt *MockTable) Operation1() error { return nil }
80 func (mt *MockTable) Operation2() error { return nil }
81 func (mt *MockTable) Operation3() error { return nil }
82 func (mt *MockTable) State() []string { return mt.state }