dep-protobuf/editions/generated_reflection_test.cc
Mike Kruskal ea81024ddf Refactor editions infrastructure to a top-level directory.
The only public target here is the edition defaults helper macro, which can be used by external runtimes and plugins.  None of this code is C++-specific though, and should be organized higher up.  Appropriate aliases are also placed at the top level for public targets

PiperOrigin-RevId: 625392504
2024-04-16 11:13:19 -07:00

30 lines
999 B
C++

// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#include <gtest/gtest.h>
#include "editions/golden/test_messages_proto2_editions.pb.h"
namespace google {
namespace protobuf {
namespace {
using ::protobuf_test_messages::editions::proto2::TestAllTypesProto2;
// It's important that no calls that would initialize the generated pool occur
// in any tests in this file. This test guarantees that there's no mutex
// deadlock from lazily loading cpp_features.proto during reflection.
TEST(Generated, Reflection) {
TestAllTypesProto2 message;
message.GetReflection()->SetInt32(
&message, message.GetDescriptor()->FindFieldByName("optional_int32"), 1);
EXPECT_EQ(message.optional_int32(), 1);
}
} // namespace
} // namespace protobuf
} // namespace google