Skip to content

Commit

Permalink
Add wrapperpb tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pcj committed Jun 22, 2023
1 parent 18e068e commit 40a1e09
Show file tree
Hide file tree
Showing 2 changed files with 586 additions and 11 deletions.
19 changes: 10 additions & 9 deletions hasher.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ func (h *hasher) hashMap(kd, fd protoreflect.FieldDescriptor, m protoreflect.Map
}

func (h *hasher) hashWellKnownType(md protoreflect.MessageDescriptor, msg protoreflect.Message) (hash []byte, err error, ok bool) {
switch md.FullName() {
fullName := md.FullName()
switch fullName {
case protoreflect.FullName("google.protobuf.Any"):
hash, err = h.hashGoogleProtobufAny(md, msg)
case protoreflect.FullName("google.protobuf.Duration"):
Expand All @@ -299,11 +300,11 @@ func (h *hasher) hashWellKnownType(md protoreflect.MessageDescriptor, msg protor
hash, err = h.hashGoogleProtobufFloatValue(md, msg)
case protoreflect.FullName("google.protobuf.Int64Value"):
hash, err = h.hashGoogleProtobufInt64Value(md, msg)
case protoreflect.FullName("google.protobuf.Uint64Value"):
case protoreflect.FullName("google.protobuf.UInt64Value"):
hash, err = h.hashGoogleProtobufUint64Value(md, msg)
case protoreflect.FullName("google.protobuf.Int32Value"):
hash, err = h.hashGoogleProtobufInt32Value(md, msg)
case protoreflect.FullName("google.protobuf.Uint32Value"):
case protoreflect.FullName("google.protobuf.UInt32Value"):
hash, err = h.hashGoogleProtobufUint32Value(md, msg)
case protoreflect.FullName("google.protobuf.BoolValue"):
hash, err = h.hashGoogleProtobufBoolValue(md, msg)
Expand Down Expand Up @@ -353,22 +354,22 @@ func (h *hasher) hashGoogleProtobufFloatValue(md protoreflect.MessageDescriptor,
return h.hashFloat(msg.Get(md.Fields().ByName(valueName)).Float())
}

func (h *hasher) hashGoogleProtobufInt64Value(md protoreflect.MessageDescriptor, msg protoreflect.Message) ([]byte, error) {
func (h *hasher) hashGoogleProtobufInt32Value(md protoreflect.MessageDescriptor, msg protoreflect.Message) ([]byte, error) {
return h.hashInt(msg.Get(md.Fields().ByName(valueName)).Int())
}

func (h *hasher) hashGoogleProtobufUint64Value(md protoreflect.MessageDescriptor, msg protoreflect.Message) ([]byte, error) {
return h.hashUint(msg.Get(md.Fields().ByName(valueName)).Uint())
}

func (h *hasher) hashGoogleProtobufInt32Value(md protoreflect.MessageDescriptor, msg protoreflect.Message) ([]byte, error) {
func (h *hasher) hashGoogleProtobufInt64Value(md protoreflect.MessageDescriptor, msg protoreflect.Message) ([]byte, error) {
return h.hashInt(msg.Get(md.Fields().ByName(valueName)).Int())
}

func (h *hasher) hashGoogleProtobufUint32Value(md protoreflect.MessageDescriptor, msg protoreflect.Message) ([]byte, error) {
return h.hashUint(msg.Get(md.Fields().ByName(valueName)).Uint())
}

func (h *hasher) hashGoogleProtobufUint64Value(md protoreflect.MessageDescriptor, msg protoreflect.Message) ([]byte, error) {
return h.hashUint(msg.Get(md.Fields().ByName(valueName)).Uint())
}

func (h *hasher) hashGoogleProtobufBoolValue(md protoreflect.MessageDescriptor, msg protoreflect.Message) ([]byte, error) {
return h.hashBool(msg.Get(md.Fields().ByName(valueName)).Bool())
}
Expand Down

0 comments on commit 40a1e09

Please sign in to comment.