Skip to content

Commit

Permalink
Internal changes
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 695503795
  • Loading branch information
mkruskal-google authored and copybara-github committed Nov 14, 2024
1 parent f50d630 commit fb1a4fb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/google/protobuf/descriptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9877,7 +9877,8 @@ bool IsStringFieldWithPrivatizedAccessors(const FieldDescriptor& field) {
.GetExtension(pb::cpp)
.string_type() == pb::CppFeatures::CORD &&
(field.type() != FieldDescriptor::TYPE_BYTES || field.is_repeated() ||
field.is_extension())) {
field.is_extension())
) {
return true;
}

Expand Down
16 changes: 16 additions & 0 deletions src/google/protobuf/descriptor_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10117,6 +10117,19 @@ TEST_F(FeaturesTest, FieldCppStringType) {
}
}
} $0
extension_range { start: 100 end: 200 }
}
extension {
name: "cord_ext"
number: 100
label: LABEL_OPTIONAL
type: TYPE_STRING
options {
features {
[pb.cpp] { string_type: CORD }
}
}
extendee: "Foo"
}
)pb",
""
Expand All @@ -10127,12 +10140,15 @@ TEST_F(FeaturesTest, FieldCppStringType) {
const FieldDescriptor* str = message->field(1);
const FieldDescriptor* cord = message->field(2);
const FieldDescriptor* cord_bytes = message->field(3);
const FieldDescriptor* cord_ext = file->extension(0);

EXPECT_EQ(view->cpp_string_type(), FieldDescriptor::CppStringType::kView);
EXPECT_EQ(str->cpp_string_type(), FieldDescriptor::CppStringType::kString);
EXPECT_EQ(cord_bytes->cpp_string_type(),
FieldDescriptor::CppStringType::kCord);
EXPECT_EQ(cord->cpp_string_type(), FieldDescriptor::CppStringType::kString);
EXPECT_EQ(cord_ext->cpp_string_type(),
FieldDescriptor::CppStringType::kString);

}

Expand Down

0 comments on commit fb1a4fb

Please sign in to comment.