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>
diff --git a/internal/impl/message_reflect_test.go b/internal/impl/message_reflect_test.go
index 82d5f81..bb6bda5 100644
--- a/internal/impl/message_reflect_test.go
+++ b/internal/impl/message_reflect_test.go
@@ -1437,6 +1437,17 @@
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.