From d4fc727be4730616ac9f95a547bb1adaa5c02687 Mon Sep 17 00:00:00 2001 From: Hong Shin Date: Mon, 26 Aug 2024 11:02:16 -0700 Subject: [PATCH] Abrogate protos::Parse with hpb::Parse PiperOrigin-RevId: 667643856 --- hpb/internal/message_lock_test.cc | 3 +-- hpb_generator/tests/test_generated.cc | 18 +++++++++--------- protos/protos.h | 1 - 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/hpb/internal/message_lock_test.cc b/hpb/internal/message_lock_test.cc index f435f7574c..74261ac213 100644 --- a/hpb/internal/message_lock_test.cc +++ b/hpb/internal/message_lock_test.cc @@ -58,8 +58,7 @@ void TestConcurrentExtensionAccess(::hpb::ExtensionRegistry registry) { ::hpb::internal::upb_extension_locker_global.store(&lock_func, std::memory_order_release); const std::string payload = GenerateTestData(); - TestModel parsed_model = - ::protos::Parse(payload, registry).value(); + TestModel parsed_model = ::hpb::Parse(payload, registry).value(); const auto test_main = [&] { EXPECT_EQ("str", parsed_model.str1()); }; const auto test_theme = [&] { ASSERT_TRUE(::hpb::HasExtension(&parsed_model, theme)); diff --git a/hpb_generator/tests/test_generated.cc b/hpb_generator/tests/test_generated.cc index f7954c78cf..67a7429d8e 100644 --- a/hpb_generator/tests/test_generated.cc +++ b/hpb_generator/tests/test_generated.cc @@ -888,7 +888,7 @@ TEST(CppGeneratedCode, SerializeUsingArena) { ::upb::Arena arena; absl::StatusOr bytes = ::hpb::Serialize(&model, arena); EXPECT_EQ(true, bytes.ok()); - TestModel parsed_model = ::protos::Parse(bytes.value()).value(); + TestModel parsed_model = ::hpb::Parse(bytes.value()).value(); EXPECT_EQ("Hello World", parsed_model.str1()); } @@ -900,7 +900,7 @@ TEST(CppGeneratedCode, SerializeProxyUsingArena) { absl::StatusOr bytes = ::hpb::Serialize(&model_proxy, arena); EXPECT_EQ(true, bytes.ok()); - TestModel parsed_model = ::protos::Parse(bytes.value()).value(); + TestModel parsed_model = ::hpb::Parse(bytes.value()).value(); EXPECT_EQ("Hello World", parsed_model.str1()); } @@ -911,7 +911,7 @@ TEST(CppGeneratedCode, SerializeNestedMessageUsingArena) { ::hpb::Ptr child = model.recursive_child(); absl::StatusOr bytes = ::hpb::Serialize(child, arena); EXPECT_EQ(true, bytes.ok()); - TestModel parsed_model = ::protos::Parse(bytes.value()).value(); + TestModel parsed_model = ::hpb::Parse(bytes.value()).value(); EXPECT_EQ("Hello World", parsed_model.str1()); } @@ -924,7 +924,7 @@ TEST(CppGeneratedCode, Parse) { ::upb::Arena arena; auto bytes = ::hpb::Serialize(&model, arena); EXPECT_EQ(true, bytes.ok()); - TestModel parsed_model = ::protos::Parse(bytes.value()).value(); + TestModel parsed_model = ::hpb::Parse(bytes.value()).value(); EXPECT_EQ("Test123", parsed_model.str1()); EXPECT_EQ(true, ::protos::GetExtension(&parsed_model, theme).ok()); } @@ -939,7 +939,7 @@ TEST(CppGeneratedCode, ParseIntoPtrToModel) { auto bytes = ::hpb::Serialize(&model, arena); EXPECT_EQ(true, bytes.ok()); ::hpb::Ptr parsed_model = ::hpb::CreateMessage(arena); - EXPECT_TRUE(::protos::Parse(parsed_model, bytes.value())); + EXPECT_TRUE(::hpb::Parse(parsed_model, bytes.value())); EXPECT_EQ("Test123", parsed_model->str1()); // Should return an extension even if we don't pass ExtensionRegistry // by promoting unknown. @@ -961,7 +961,7 @@ TEST(CppGeneratedCode, ParseWithExtensionRegistry) { ::hpb::ExtensionRegistry extensions( {&theme, &other_ext, &ThemeExtension::theme_extension}, arena); TestModel parsed_model = - ::protos::Parse(bytes.value(), extensions).value(); + ::hpb::Parse(bytes.value(), extensions).value(); EXPECT_EQ("Test123", parsed_model.str1()); EXPECT_EQ(true, ::protos::GetExtension(&parsed_model, theme).ok()); EXPECT_EQ(true, ::protos::GetExtension(&parsed_model, @@ -985,14 +985,14 @@ TEST(CppGeneratedCode, SharedPointer) { std::shared_ptr model = std::make_shared(); ::upb::Arena arena; auto bytes = ::hpb::Serialize(model.get(), arena); - EXPECT_TRUE(::protos::Parse(model.get(), bytes.value())); + EXPECT_TRUE(::hpb::Parse(model.get(), bytes.value())); } TEST(CppGeneratedCode, UniquePointer) { auto model = std::make_unique(); ::upb::Arena arena; auto bytes = ::hpb::Serialize(model.get(), arena); - EXPECT_TRUE(::protos::Parse(model.get(), bytes.value())); + EXPECT_TRUE(::hpb::Parse(model.get(), bytes.value())); } TEST(CppGeneratedCode, Assignment) { @@ -1224,7 +1224,7 @@ TEST(CppGeneratedCode, HasExtensionAndRegistry) { // Test with ExtensionRegistry ::hpb::ExtensionRegistry extensions({&theme}, arena); - TestModel parsed_model = ::protos::Parse(data, extensions).value(); + TestModel parsed_model = ::hpb::Parse(data, extensions).value(); EXPECT_TRUE(::hpb::HasExtension(&parsed_model, theme)); } diff --git a/protos/protos.h b/protos/protos.h index 617447e9d5..48e6f1c2ba 100644 --- a/protos/protos.h +++ b/protos/protos.h @@ -21,7 +21,6 @@ typename T::CProxy CreateMessage(const upb_Message* msg, upb_Arena* arena) { return hpb::interop::upb::MakeCHandle(msg, arena); } } // namespace internal -using hpb::Parse; using hpb::Serialize; using hpb::GetExtension;