mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-03-10 07:14:24 +00:00
internal/impl: fix reversed IsValid test
Change-Id: Iaf5291a6bf31ad3dd130fca06840cec66b896f59 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/211558 Reviewed-by: Joe Tsai <joetsai@google.com>
This commit is contained in:
parent
d65001875f
commit
b120a23bc8
@ -741,7 +741,7 @@ func (m *{{.}}) SetUnknown(b protoreflect.RawFields) {
|
||||
m.messageInfo().setUnknown(m.pointer(), b)
|
||||
}
|
||||
func (m *{{.}}) IsValid() bool {
|
||||
return m.pointer().IsNil()
|
||||
return !m.pointer().IsNil()
|
||||
}
|
||||
|
||||
{{end}}
|
||||
|
@ -125,7 +125,7 @@ func (m *messageState) SetUnknown(b protoreflect.RawFields) {
|
||||
m.messageInfo().setUnknown(m.pointer(), b)
|
||||
}
|
||||
func (m *messageState) IsValid() bool {
|
||||
return m.pointer().IsNil()
|
||||
return !m.pointer().IsNil()
|
||||
}
|
||||
|
||||
func (m *messageReflectWrapper) Descriptor() protoreflect.MessageDescriptor {
|
||||
@ -245,5 +245,5 @@ func (m *messageReflectWrapper) SetUnknown(b protoreflect.RawFields) {
|
||||
m.messageInfo().setUnknown(m.pointer(), b)
|
||||
}
|
||||
func (m *messageReflectWrapper) IsValid() bool {
|
||||
return m.pointer().IsNil()
|
||||
return !m.pointer().IsNil()
|
||||
}
|
||||
|
@ -1437,6 +1437,17 @@ func TestReset(t *testing.T) {
|
||||
m.Descriptor()
|
||||
}
|
||||
|
||||
func TestIsValid(t *testing.T) {
|
||||
var m *testpb.TestAllTypes
|
||||
if got, want := m.ProtoReflect().IsValid(), false; got != want {
|
||||
t.Errorf("((*M)(nil)).ProtoReflect().IsValid() = %v, want %v", got, want)
|
||||
}
|
||||
m = &testpb.TestAllTypes{}
|
||||
if got, want := m.ProtoReflect().IsValid(), true; got != want {
|
||||
t.Errorf("(&M{}).ProtoReflect().IsValid() = %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// The MessageState implementation makes the assumption that when a
|
||||
// concrete message is unsafe casted as a *MessageState, the Go GC does
|
||||
// not reclaim the memory for the remainder of the concrete message.
|
||||
|
Loading…
x
Reference in New Issue
Block a user