Have MSVC use the preexisting __builtin_offsetof() case for GCC.
[google-protobuf.git] / editions / generated_reflection_test.cc
blobb991299e3ca517a31c81d4d2787ae48a3214a849
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2023 Google Inc. All rights reserved.
3 //
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file or at
6 // https://developers.google.com/open-source/licenses/bsd
8 #include <gtest/gtest.h>
9 #include "editions/golden/test_messages_proto2_editions.pb.h"
11 namespace google {
12 namespace protobuf {
13 namespace {
15 using ::protobuf_test_messages::editions::proto2::TestAllTypesProto2;
17 // It's important that no calls that would initialize the generated pool occur
18 // in any tests in this file. This test guarantees that there's no mutex
19 // deadlock from lazily loading cpp_features.proto during reflection.
20 TEST(Generated, Reflection) {
21 TestAllTypesProto2 message;
23 message.GetReflection()->SetInt32(
24 &message, message.GetDescriptor()->FindFieldByName("optional_int32"), 1);
25 EXPECT_EQ(message.optional_int32(), 1);
28 } // namespace
29 } // namespace protobuf
30 } // namespace google