Skip to content

Commit 9100b0a

Browse files
Internal change
PiperOrigin-RevId: 850065364
1 parent 50d0621 commit 9100b0a

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

src/google/protobuf/compiler/parser.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ const TypeNameMap& GetUnstableVarintTypeNameTable() {
8181

8282
result["varint32"] = FieldDescriptorProto::TYPE_INT32;
8383
result["varint64"] = FieldDescriptorProto::TYPE_INT64;
84+
result["uvarint32"] = FieldDescriptorProto::TYPE_UINT32;
85+
result["uvarint64"] = FieldDescriptorProto::TYPE_UINT64;
8486
result["zigzag32"] = FieldDescriptorProto::TYPE_SINT32;
8587
result["zigzag64"] = FieldDescriptorProto::TYPE_SINT64;
8688

src/google/protobuf/compiler/parser_unittest.cc

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,62 @@ message NewVarintTypes {
641641
"2:2: \"zigzag64\" is not defined.\n");
642642
}
643643

644+
TEST_F(ParseMessageTest, Uvarint32Unstable) {
645+
ExpectParsesTo(
646+
R"(edition = "UNSTABLE";
647+
message NewVarintTypes {
648+
uvarint32 uint32_field = 1;
649+
})",
650+
R"(message_type {
651+
name: "NewVarintTypes"
652+
field {
653+
name: "uint32_field"
654+
number: 1
655+
label: LABEL_OPTIONAL
656+
type: TYPE_UINT32
657+
}
658+
}
659+
syntax: "editions"
660+
edition: EDITION_UNSTABLE)");
661+
}
662+
663+
TEST_F(ParseMessageTest, Uvarint32StableFails) {
664+
ExpectHasValidationErrors(
665+
R"(edition = "2024";
666+
message NewVarintTypes {
667+
uvarint32 uint32_field = 1;
668+
})",
669+
"2:2: \"uvarint32\" is not defined.\n");
670+
}
671+
672+
TEST_F(ParseMessageTest, Uvarint64Unstable) {
673+
ExpectParsesTo(
674+
R"(edition = "UNSTABLE";
675+
message NewVarintTypes {
676+
uvarint64 uint64_field = 1;
677+
})",
678+
R"(message_type {
679+
name: "NewVarintTypes"
680+
field {
681+
name: "uint64_field"
682+
number: 1
683+
label: LABEL_OPTIONAL
684+
type: TYPE_UINT64
685+
}
686+
}
687+
syntax: "editions"
688+
edition: EDITION_UNSTABLE)");
689+
}
690+
691+
TEST_F(ParseMessageTest, Uvarint64StableFails) {
692+
ExpectHasValidationErrors(
693+
R"(edition = "2024";
694+
message NewVarintTypes {
695+
uvarint64 uint64_field = 1;
696+
})",
697+
"2:2: \"uvarint64\" is not defined.\n");
698+
}
699+
644700
TEST_F(ParseMessageTest, FieldOptions) {
645701
ExpectParsesTo(
646702
"message TestMessage {\n"

0 commit comments

Comments
 (0)