Skip to content

Commit

Permalink
Add a conformance test for unmatched start group tag.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 694345563
  • Loading branch information
mkruskal-google authored and copybara-github committed Nov 8, 2024
1 parent a4a1e7f commit 2177a2e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
21 changes: 19 additions & 2 deletions conformance/binary_json_conformance_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ void BinaryAndJsonConformanceSuiteImpl<MessageType>::TestIllegalTags() {
}

template <typename MessageType>
void BinaryAndJsonConformanceSuiteImpl<MessageType>::TestUnmatchedEndGroup() {
void BinaryAndJsonConformanceSuiteImpl<MessageType>::TestUnmatchedGroup() {
ExpectParseFailureForProto(tag(201, WireFormatLite::WIRETYPE_END_GROUP),
"UnmatchedEndGroup", REQUIRED);
ExpectParseFailureForProto(tag(1234, WireFormatLite::WIRETYPE_END_GROUP),
Expand All @@ -1384,6 +1384,23 @@ void BinaryAndJsonConformanceSuiteImpl<MessageType>::TestUnmatchedEndGroup() {
absl::StrCat(tag(1, WireFormatLite::WIRETYPE_END_GROUP),
len(2, "hello world")),
"UnmatchedEndGroupWithData", REQUIRED);

ExpectParseFailureForProto(tag(201, WireFormatLite::WIRETYPE_START_GROUP),
"UnmatchedStartGroup", REQUIRED);
ExpectParseFailureForProto(tag(1234, WireFormatLite::WIRETYPE_START_GROUP),
"UnmatchedStartGroupUnknown", REQUIRED);
ExpectParseFailureForProto(tag(1, WireFormatLite::WIRETYPE_START_GROUP),
"UnmatchedStartGroupWrongType", REQUIRED);
ExpectParseFailureForProto(
len(18, tag(1234, WireFormatLite::WIRETYPE_START_GROUP)),
"UnmatchedStartGroupNestedLen", REQUIRED);
ExpectParseFailureForProto(
group(201, tag(202, WireFormatLite::WIRETYPE_START_GROUP)),
"UnmatchedStartGroupNested", REQUIRED);
ExpectParseFailureForProto(
absl::StrCat(tag(1, WireFormatLite::WIRETYPE_START_GROUP),
len(2, "hello world")),
"UnmatchedStartGroupWithData", REQUIRED);
}

template <typename MessageType>
Expand Down Expand Up @@ -1573,7 +1590,7 @@ void BinaryAndJsonConformanceSuiteImpl<MessageType>::RunAllTests() {
}

TestIllegalTags();
TestUnmatchedEndGroup();
TestUnmatchedGroup();
TestUnknownWireType();

int64_t kInt64Min = -9223372036854775808ULL;
Expand Down
2 changes: 1 addition & 1 deletion conformance/binary_json_conformance_suite.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class BinaryAndJsonConformanceSuiteImpl {
ConformanceLevel level);
void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type);
void TestIllegalTags();
void TestUnmatchedEndGroup();
void TestUnmatchedGroup();
void TestUnknownWireType();
void TestOneofMessage();
void TestUnknownMessage();
Expand Down
17 changes: 0 additions & 17 deletions csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs

This file was deleted.

0 comments on commit 2177a2e

Please sign in to comment.