Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / github.com / google / go-cmp@v0.5.1 / cmp / internal / teststructs / project4.go
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.
4
5 package teststructs
6
7 import (
8         "time"
9
10         pb "github.com/google/go-cmp/cmp/internal/testprotos"
11 )
12
13 // This is an sanitized example of equality from a real use-case.
14 // The original equality function was as follows:
15 /*
16 func equalCartel(x, y Cartel) bool {
17         if !(equalHeadquarter(x.Headquarter, y.Headquarter) &&
18                 x.Source() == y.Source() &&
19                 x.CreationDate().Equal(y.CreationDate()) &&
20                 x.Boss() == y.Boss() &&
21                 x.LastCrimeDate().Equal(y.LastCrimeDate())) {
22                 return false
23         }
24         if len(x.Poisons()) != len(y.Poisons()) {
25                 return false
26         }
27         for i := range x.Poisons() {
28                 if !equalPoison(*x.Poisons()[i], *y.Poisons()[i]) {
29                         return false
30                 }
31         }
32         return true
33 }
34 func equalHeadquarter(x, y Headquarter) bool {
35         xr, yr := x.Restrictions(), y.Restrictions()
36         return x.ID() == y.ID() &&
37                 x.Location() == y.Location() &&
38                 reflect.DeepEqual(x.SubDivisions(), y.SubDivisions()) &&
39                 x.IncorporatedDate().Equal(y.IncorporatedDate()) &&
40                 pb.Equal(x.MetaData(), y.MetaData()) &&
41                 bytes.Equal(x.PrivateMessage(), y.PrivateMessage()) &&
42                 bytes.Equal(x.PublicMessage(), y.PublicMessage()) &&
43                 x.HorseBack() == y.HorseBack() &&
44                 x.Rattle() == y.Rattle() &&
45                 x.Convulsion() == y.Convulsion() &&
46                 x.Expansion() == y.Expansion() &&
47                 x.Status() == y.Status() &&
48                 pb.Equal(&xr, &yr) &&
49                 x.CreationTime().Equal(y.CreationTime())
50 }
51 func equalPoison(x, y Poison) bool {
52         return x.PoisonType() == y.PoisonType() &&
53                 x.Expiration().Equal(y.Expiration()) &&
54                 x.Manufacturer() == y.Manufacturer() &&
55                 x.Potency() == y.Potency()
56 }
57 */
58
59 type Cartel struct {
60         Headquarter
61         source        string
62         creationDate  time.Time
63         boss          string
64         lastCrimeDate time.Time
65         poisons       []*Poison
66 }
67
68 func (p Cartel) Source() string           { return p.source }
69 func (p Cartel) CreationDate() time.Time  { return p.creationDate }
70 func (p Cartel) Boss() string             { return p.boss }
71 func (p Cartel) LastCrimeDate() time.Time { return p.lastCrimeDate }
72 func (p Cartel) Poisons() []*Poison       { return p.poisons }
73
74 func (p *Cartel) SetSource(x string)           { p.source = x }
75 func (p *Cartel) SetCreationDate(x time.Time)  { p.creationDate = x }
76 func (p *Cartel) SetBoss(x string)             { p.boss = x }
77 func (p *Cartel) SetLastCrimeDate(x time.Time) { p.lastCrimeDate = x }
78 func (p *Cartel) SetPoisons(x []*Poison)       { p.poisons = x }
79
80 type Headquarter struct {
81         id               uint64
82         location         string
83         subDivisions     []string
84         incorporatedDate time.Time
85         metaData         *pb.MetaData
86         privateMessage   []byte
87         publicMessage    []byte
88         horseBack        string
89         rattle           string
90         convulsion       bool
91         expansion        uint64
92         status           pb.HoneyStatus
93         restrictions     pb.Restrictions
94         creationTime     time.Time
95 }
96
97 func (hq Headquarter) ID() uint64                    { return hq.id }
98 func (hq Headquarter) Location() string              { return hq.location }
99 func (hq Headquarter) SubDivisions() []string        { return hq.subDivisions }
100 func (hq Headquarter) IncorporatedDate() time.Time   { return hq.incorporatedDate }
101 func (hq Headquarter) MetaData() *pb.MetaData        { return hq.metaData }
102 func (hq Headquarter) PrivateMessage() []byte        { return hq.privateMessage }
103 func (hq Headquarter) PublicMessage() []byte         { return hq.publicMessage }
104 func (hq Headquarter) HorseBack() string             { return hq.horseBack }
105 func (hq Headquarter) Rattle() string                { return hq.rattle }
106 func (hq Headquarter) Convulsion() bool              { return hq.convulsion }
107 func (hq Headquarter) Expansion() uint64             { return hq.expansion }
108 func (hq Headquarter) Status() pb.HoneyStatus        { return hq.status }
109 func (hq Headquarter) Restrictions() pb.Restrictions { return hq.restrictions }
110 func (hq Headquarter) CreationTime() time.Time       { return hq.creationTime }
111
112 func (hq *Headquarter) SetID(x uint64)                    { hq.id = x }
113 func (hq *Headquarter) SetLocation(x string)              { hq.location = x }
114 func (hq *Headquarter) SetSubDivisions(x []string)        { hq.subDivisions = x }
115 func (hq *Headquarter) SetIncorporatedDate(x time.Time)   { hq.incorporatedDate = x }
116 func (hq *Headquarter) SetMetaData(x *pb.MetaData)        { hq.metaData = x }
117 func (hq *Headquarter) SetPrivateMessage(x []byte)        { hq.privateMessage = x }
118 func (hq *Headquarter) SetPublicMessage(x []byte)         { hq.publicMessage = x }
119 func (hq *Headquarter) SetHorseBack(x string)             { hq.horseBack = x }
120 func (hq *Headquarter) SetRattle(x string)                { hq.rattle = x }
121 func (hq *Headquarter) SetConvulsion(x bool)              { hq.convulsion = x }
122 func (hq *Headquarter) SetExpansion(x uint64)             { hq.expansion = x }
123 func (hq *Headquarter) SetStatus(x pb.HoneyStatus)        { hq.status = x }
124 func (hq *Headquarter) SetRestrictions(x pb.Restrictions) { hq.restrictions = x }
125 func (hq *Headquarter) SetCreationTime(x time.Time)       { hq.creationTime = x }
126
127 type Poison struct {
128         poisonType   pb.PoisonType
129         expiration   time.Time
130         manufacturer string
131         potency      int
132 }
133
134 func (p Poison) PoisonType() pb.PoisonType { return p.poisonType }
135 func (p Poison) Expiration() time.Time     { return p.expiration }
136 func (p Poison) Manufacturer() string      { return p.manufacturer }
137 func (p Poison) Potency() int              { return p.potency }
138
139 func (p *Poison) SetPoisonType(x pb.PoisonType) { p.poisonType = x }
140 func (p *Poison) SetExpiration(x time.Time)     { p.expiration = x }
141 func (p *Poison) SetManufacturer(x string)      { p.manufacturer = x }
142 func (p *Poison) SetPotency(x int)              { p.potency = x }