1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937
|
// Protocol Buffers - Google's data interchange format
// Copyright 2008 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
// Author: kenton@google.com (Kenton Varda)
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
//
// A proto file we will use for unit testing.
//
// LINT: ALLOW_GROUPS, LEGACY_NAMES
edition = "2023";
package rust_unittest;
import "rust/test/unittest_import.proto";
option features = { enum_type : CLOSED, repeated_field_encoding : EXPANDED, utf8_validation : NONE };
option cc_enable_arenas = true;
// Protos optimized for SPEED use a strict superset of the generated code
// of equivalent ones optimized for CODE_SIZE, so we should optimize all our
// tests for speed unless explicitly testing code size optimization.
option optimize_for = SPEED;
// This proto includes every type of field in both singular and repeated
// forms.
message TestAllTypes {
message NestedMessage {
// The field name "b" fails to compile in proto1 because it conflicts with
// a local variable named "b" in one of the generated methods. Doh.
// This file needs to compile in proto1 to test backwards-compatibility.
int32 bb = 1;
}
enum NestedEnum {
FOO = 1;
BAR = 2;
BAZ = 3;
NEG = -1; // Intentionally negative.
}
// Singular
int32 optional_int32 = 1;
int64 optional_int64 = 2;
uint32 optional_uint32 = 3;
uint64 optional_uint64 = 4;
sint32 optional_sint32 = 5;
sint64 optional_sint64 = 6;
fixed32 optional_fixed32 = 7;
fixed64 optional_fixed64 = 8;
sfixed32 optional_sfixed32 = 9;
sfixed64 optional_sfixed64 = 10;
float optional_float = 11;
double optional_double = 12;
bool optional_bool = 13;
string optional_string = 14;
bytes optional_bytes = 15;
message OptionalGroup {
int32 a = 17;
}
OptionalGroup optionalgroup = 16 [features.message_encoding = DELIMITED];
NestedMessage optional_nested_message = 18;
ForeignMessage optional_foreign_message = 19;
rust_unittest_import.ImportMessage optional_import_message = 20;
NestedEnum optional_nested_enum = 21;
ForeignEnum optional_foreign_enum = 22;
rust_unittest_import.ImportEnum optional_import_enum = 23;
string optional_string_piece = 24 [ctype = STRING_PIECE];
string optional_cord = 25 [ctype = CORD];
bytes optional_bytes_cord = 86 [ctype = CORD];
NestedMessage optional_lazy_message = 27 [lazy = true];
// Repeated
repeated int32 repeated_int32 = 31;
repeated int64 repeated_int64 = 32;
repeated uint32 repeated_uint32 = 33;
repeated uint64 repeated_uint64 = 34;
repeated sint32 repeated_sint32 = 35;
repeated sint64 repeated_sint64 = 36;
repeated fixed32 repeated_fixed32 = 37;
repeated fixed64 repeated_fixed64 = 38;
repeated sfixed32 repeated_sfixed32 = 39;
repeated sfixed64 repeated_sfixed64 = 40;
repeated float repeated_float = 41;
repeated double repeated_double = 42;
repeated bool repeated_bool = 43;
repeated string repeated_string = 44;
repeated bytes repeated_bytes = 45;
message RepeatedGroup {
int32 a = 47;
}
repeated RepeatedGroup repeatedgroup = 46
[features.message_encoding = DELIMITED];
repeated NestedMessage repeated_nested_message = 48;
repeated ForeignMessage repeated_foreign_message = 49;
repeated rust_unittest_import.ImportMessage repeated_import_message = 50;
repeated NestedEnum repeated_nested_enum = 51;
repeated ForeignEnum repeated_foreign_enum = 52;
repeated rust_unittest_import.ImportEnum repeated_import_enum = 53;
repeated string repeated_string_piece = 54 [ctype = STRING_PIECE];
repeated string repeated_cord = 55 [ctype = CORD];
// Singular with defaults
int32 default_int32 = 61 [default = 41];
int64 default_int64 = 62 [default = 42];
uint32 default_uint32 = 63 [default = 43];
uint64 default_uint64 = 64 [default = 44];
sint32 default_sint32 = 65 [default = -45];
sint64 default_sint64 = 66 [default = 46];
fixed32 default_fixed32 = 67 [default = 47];
fixed64 default_fixed64 = 68 [default = 48];
sfixed32 default_sfixed32 = 69 [default = 49];
sfixed64 default_sfixed64 = 70 [default = -50];
float default_float = 71 [default = 51.5];
double default_double = 72 [default = 5.2e4];
bool default_bool = 73 [default = true];
string default_string = 74 [default = "hello"];
bytes default_bytes = 75 [default = "world"];
NestedEnum default_nested_enum = 81 [default = BAR];
ForeignEnum default_foreign_enum = 82 [default = FOREIGN_BAR];
rust_unittest_import.ImportEnum default_import_enum = 83
[default = IMPORT_BAR];
string default_string_piece = 84 [ctype = STRING_PIECE, default = "abc"];
string default_cord = 85 [ctype = CORD, default = "123"];
// For oneof test
oneof oneof_field {
uint32 oneof_uint32 = 111;
NestedMessage oneof_nested_message = 112;
string oneof_string = 113;
bytes oneof_bytes = 114;
string oneof_cord = 115 [ctype = CORD];
string oneof_string_piece = 116 [ctype = STRING_PIECE];
NestedMessage oneof_lazy_nested_message = 117 [lazy = true];
}
}
// This proto includes a recursively nested message.
message NestedTestAllTypes {
NestedTestAllTypes child = 1;
TestAllTypes payload = 2;
repeated NestedTestAllTypes repeated_child = 3;
NestedTestAllTypes lazy_child = 4 [lazy = true];
TestAllTypes eager_child = 5 [lazy = false];
}
message TestDeprecatedFields {
int32 deprecated_int32 = 1 [deprecated = true];
repeated string deprecated_repeated_string = 4 [deprecated = true];
TestAllTypes.NestedMessage deprecated_message = 3 [deprecated = true];
oneof oneof_fields {
int32 deprecated_int32_in_oneof = 2 [deprecated = true];
}
TestDeprecatedFields nested = 5;
}
message TestDeprecatedMessage {
option deprecated = true;
}
// Define these after TestAllTypes to make sure the compiler can handle
// that.
message ForeignMessage {
int32 c = 1;
int32 d = 2;
}
enum ForeignEnum {
FOREIGN_FOO = 4;
FOREIGN_BAR = 5;
FOREIGN_BAZ = 6;
FOREIGN_BAX = 32; // (1 << 32) to generate a 64b bitmask would be incorrect.
FOREIGN_LARGE = 123456; // Large enough to escape the Boxed Integer cache.
}
enum TestDeprecatedEnum {
option deprecated = true;
TEST_DEPRECATED_ENUM_UNSPECIFIED = 0;
TEST_DEPRECATED_ENUM_VALUE1 = 1;
TEST_DEPRECATED_ENUM_VALUE2 = 2;
}
message TestReservedFields {
reserved 2, 15, 9 to 11;
reserved bar, baz;
}
enum TestReservedEnumFields {
UNKNOWN = 0;
reserved 2, 15, 9 to 11;
reserved bar, baz;
}
message TestAllExtensions {
extensions 1 to max;
}
extend TestAllExtensions {
// Singular
int32 optional_int32_extension = 1;
int64 optional_int64_extension = 2;
uint32 optional_uint32_extension = 3;
uint64 optional_uint64_extension = 4;
sint32 optional_sint32_extension = 5;
sint64 optional_sint64_extension = 6;
fixed32 optional_fixed32_extension = 7;
fixed64 optional_fixed64_extension = 8;
sfixed32 optional_sfixed32_extension = 9;
sfixed64 optional_sfixed64_extension = 10;
float optional_float_extension = 11;
double optional_double_extension = 12;
bool optional_bool_extension = 13;
string optional_string_extension = 14;
bytes optional_bytes_extension = 15;
OptionalGroup_extension optionalgroup_extension = 16
[features.message_encoding = DELIMITED];
TestAllTypes.NestedMessage optional_nested_message_extension = 18;
ForeignMessage optional_foreign_message_extension = 19;
rust_unittest_import.ImportMessage optional_import_message_extension = 20;
TestAllTypes.NestedEnum optional_nested_enum_extension = 21;
ForeignEnum optional_foreign_enum_extension = 22;
rust_unittest_import.ImportEnum optional_import_enum_extension = 23;
string optional_string_piece_extension = 24 [ctype = STRING_PIECE];
// TODO: ctype=CORD is not supported for extension. Add
// ctype=CORD option back after it is supported.
string optional_cord_extension = 25;
bytes optional_bytes_cord_extension = 86;
TestAllTypes.NestedMessage optional_lazy_message_extension = 27 [lazy = true];
// Repeated
repeated int32 repeated_int32_extension = 31;
repeated int64 repeated_int64_extension = 32;
repeated uint32 repeated_uint32_extension = 33;
repeated uint64 repeated_uint64_extension = 34;
repeated sint32 repeated_sint32_extension = 35;
repeated sint64 repeated_sint64_extension = 36;
repeated fixed32 repeated_fixed32_extension = 37;
repeated fixed64 repeated_fixed64_extension = 38;
repeated sfixed32 repeated_sfixed32_extension = 39;
repeated sfixed64 repeated_sfixed64_extension = 40;
repeated float repeated_float_extension = 41;
repeated double repeated_double_extension = 42;
repeated bool repeated_bool_extension = 43;
repeated string repeated_string_extension = 44;
repeated bytes repeated_bytes_extension = 45;
repeated RepeatedGroup_extension repeatedgroup_extension = 46
[features.message_encoding = DELIMITED];
repeated TestAllTypes.NestedMessage repeated_nested_message_extension = 48;
repeated ForeignMessage repeated_foreign_message_extension = 49;
repeated rust_unittest_import.ImportMessage
repeated_import_message_extension = 50;
repeated TestAllTypes.NestedEnum repeated_nested_enum_extension = 51;
repeated ForeignEnum repeated_foreign_enum_extension = 52;
repeated rust_unittest_import.ImportEnum repeated_import_enum_extension = 53;
repeated string repeated_string_piece_extension = 54 [ctype = STRING_PIECE];
// TODO: ctype=CORD is not supported for extension. Add
// ctype=CORD option back after it is supported.
repeated string repeated_cord_extension = 55;
// Singular with defaults
int32 default_int32_extension = 61 [default = 41];
int64 default_int64_extension = 62 [default = 42];
uint32 default_uint32_extension = 63 [default = 43];
uint64 default_uint64_extension = 64 [default = 44];
sint32 default_sint32_extension = 65 [default = -45];
sint64 default_sint64_extension = 66 [default = 46];
fixed32 default_fixed32_extension = 67 [default = 47];
fixed64 default_fixed64_extension = 68 [default = 48];
sfixed32 default_sfixed32_extension = 69 [default = 49];
sfixed64 default_sfixed64_extension = 70 [default = -50];
float default_float_extension = 71 [default = 51.5];
double default_double_extension = 72 [default = 5.2e4];
bool default_bool_extension = 73 [default = true];
string default_string_extension = 74 [default = "hello"];
bytes default_bytes_extension = 75 [default = "world"];
TestAllTypes.NestedEnum default_nested_enum_extension = 81 [default = BAR];
ForeignEnum default_foreign_enum_extension = 82 [default = FOREIGN_BAR];
string default_string_piece_extension = 84
[ctype = STRING_PIECE, default = "abc"];
// TODO: ctype=CORD is not supported for extension. Add
// ctype=CORD option back after it is supported.
string default_cord_extension = 85 [default = "123"];
// For oneof test
uint32 oneof_uint32_extension = 111;
TestAllTypes.NestedMessage oneof_nested_message_extension = 112;
string oneof_string_extension = 113;
bytes oneof_bytes_extension = 114;
}
message OptionalGroup_extension {
int32 a = 17;
}
message RepeatedGroup_extension {
int32 a = 47;
}
message TestMixedFieldsAndExtensions {
int32 a = 1;
repeated fixed32 b = 3;
extensions 2, 4;
extend TestMixedFieldsAndExtensions {
int32 c = 2;
repeated fixed32 d = 4;
}
}
message TestGroup {
message OptionalGroup {
int32 a = 17;
int32 zz = 89; // fast table size must be at least 16, for this
// field to be parsed by the fast parser, since
// 89 - 17 = 72 is a multiple of 8.
}
OptionalGroup optionalgroup = 16 [features.message_encoding = DELIMITED];
ForeignEnum optional_foreign_enum = 22;
}
message TestGroupExtension {
extensions 1 to max;
}
message TestNestedExtension {
extend TestAllExtensions {
// Check for bug where string extensions declared in tested scope did not
// compile.
string test = 1002 [default = "test"];
// Used to test if generated extension name is correct when there are
// underscores.
string nested_string_extension = 1003;
}
extend TestGroupExtension {
OptionalGroup_extension optionalgroup_extension = 16
[features.message_encoding = DELIMITED];
ForeignEnum optional_foreign_enum_extension = 22;
}
message OptionalGroup_extension {
int32 a = 17;
}
}
message TestChildExtension {
string a = 1;
string b = 2;
TestAllExtensions optional_extension = 3;
}
// Emulates wireformat data of TestChildExtension with dynamic extension
// (DynamicExtension).
message TestChildExtensionData {
message NestedTestAllExtensionsData {
message NestedDynamicExtensions {
int32 a = 1;
int32 b = 2;
}
NestedDynamicExtensions dynamic = 409707008;
}
string a = 1;
string b = 2;
NestedTestAllExtensionsData optional_extension = 3;
}
message TestNestedChildExtension {
int32 a = 1;
TestChildExtension child = 2;
}
// Emulates wireformat data of TestNestedChildExtension with dynamic extension
// (DynamicExtension).
message TestNestedChildExtensionData {
int32 a = 1;
TestChildExtensionData child = 2;
}
// Required and closed enum fields are considered unknown fields if the value is
// not valid. We need to make sure it functions as expected.
message TestRequiredEnum {
ForeignEnum required_enum = 1 [features.field_presence = LEGACY_REQUIRED];
// A dummy optional field.
int32 a = 2;
}
// Required and open enum accepts invalid enum values.
enum ForeignOpenEnum {
option features.enum_type = OPEN;
FOREIGN_OPEN_UNKNOWN = 0;
FOREIGN_OPEN_FOO = 4;
FOREIGN_OPEN_BAR = 5;
FOREIGN_OPEN_BAZ = 6;
FOREIGN_OPEN_BAX = 32; // (1 << 32) to generate a 64b bitmask would be
// incorrect.
}
message TestRequiredOpenEnum {
ForeignOpenEnum required_enum = 1 [features.field_presence = LEGACY_REQUIRED];
// A dummy optional field.
int32 a = 2;
}
// TestRequiredEnum + using enum values that won't fit to 64 bitmask.
message TestRequiredEnumNoMask {
enum NestedEnum {
UNSPECIFIED = 0;
FOO = 2;
BAR = 100;
BAZ = -1; // Intentionally negative.
}
NestedEnum required_enum = 1 [features.field_presence = LEGACY_REQUIRED];
// A dummy optional field.
int32 a = 2;
}
message TestRequiredEnumMulti {
enum NestedEnum {
UNSPECIFIED = 0;
FOO = 1;
BAR = 2;
BAZ = 100;
}
// Intentionally placed in descending field number to force sorting in closed
// enum verification.
NestedEnum required_enum_4 = 4 [features.field_presence = LEGACY_REQUIRED];
int32 a_3 = 3;
NestedEnum required_enum_2 = 2 [features.field_presence = LEGACY_REQUIRED];
ForeignEnum required_enum_1 = 1 [features.field_presence = LEGACY_REQUIRED];
}
message TestRequiredNoMaskMulti {
enum NestedEnum {
UNSPECIFIED = 0;
FOO = 1;
BAR = 2;
BAZ = 100;
}
// Intentionally placed in descending field number to force sorting in closed
// enum verification. Also, using large field numbers to use tag only
// matching for required fields.
fixed32 required_fixed32_80 = 80 [features.field_presence = LEGACY_REQUIRED];
fixed32 required_fixed32_70 = 70 [features.field_presence = LEGACY_REQUIRED];
NestedEnum required_enum_64 = 64 [features.field_presence = LEGACY_REQUIRED];
NestedEnum required_enum_4 = 4 [features.field_presence = LEGACY_REQUIRED];
int32 a_3 = 3;
NestedEnum required_enum_2 = 2 [features.field_presence = LEGACY_REQUIRED];
ForeignEnum required_enum_1 = 1 [features.field_presence = LEGACY_REQUIRED];
}
// We have separate messages for testing required fields because it's
// annoying to have to fill in required fields in TestProto in order to
// do anything with it. Note that we don't need to test every type of
// required filed because the code output is basically identical to
// optional fields for all types.
message TestRequired {
int32 a = 1 [features.field_presence = LEGACY_REQUIRED];
int32 dummy2 = 2;
int32 b = 3 [features.field_presence = LEGACY_REQUIRED];
extend TestAllExtensions {
TestRequired single = 1000;
repeated TestRequired multi = 1001;
}
// Pad the field count to 32 so that we can test that IsInitialized()
// properly checks multiple elements of has_bits_.
int32 dummy4 = 4;
int32 dummy5 = 5;
int32 dummy6 = 6;
int32 dummy7 = 7;
int32 dummy8 = 8;
int32 dummy9 = 9;
int32 dummy10 = 10;
int32 dummy11 = 11;
int32 dummy12 = 12;
int32 dummy13 = 13;
int32 dummy14 = 14;
int32 dummy15 = 15;
int32 dummy16 = 16;
int32 dummy17 = 17;
int32 dummy18 = 18;
int32 dummy19 = 19;
int32 dummy20 = 20;
int32 dummy21 = 21;
int32 dummy22 = 22;
int32 dummy23 = 23;
int32 dummy24 = 24;
int32 dummy25 = 25;
int32 dummy26 = 26;
int32 dummy27 = 27;
int32 dummy28 = 28;
int32 dummy29 = 29;
int32 dummy30 = 30;
int32 dummy31 = 31;
int32 dummy32 = 32;
int32 c = 33 [features.field_presence = LEGACY_REQUIRED];
// Add an optional child message to make this non-trivial for go/pdlazy.
ForeignMessage optional_foreign = 34;
}
message TestRequiredForeign {
TestRequired optional_message = 1;
repeated TestRequired repeated_message = 2;
int32 dummy = 3;
// Missing required fields must not affect verification of child messages.
NestedTestAllTypes optional_lazy_message = 4 [lazy = true];
}
message TestRequiredMessage {
TestRequired optional_message = 1;
repeated TestRequired repeated_message = 2;
TestRequired required_message = 3 [features.field_presence = LEGACY_REQUIRED];
}
message TestNestedRequiredForeign {
TestNestedRequiredForeign child = 1;
TestRequiredForeign payload = 2;
int32 dummy = 3;
// optional message to test required closed enum.
TestRequiredEnum required_enum = 5;
TestRequiredEnumNoMask required_enum_no_mask = 6;
TestRequiredEnumMulti required_enum_multi = 7;
TestRequiredNoMaskMulti required_no_mask = 9;
}
// Test that we can use NestedMessage from outside TestAllTypes.
message TestForeignNested {
TestAllTypes.NestedMessage foreign_nested = 1;
}
// TestEmptyMessage is used to test unknown field support.
message TestEmptyMessage {}
// Like above, but declare all field numbers as potential extensions. No
// actual extensions should ever be defined for this type.
message TestEmptyMessageWithExtensions {
extensions 1 to max;
}
// Needed for a Python test.
message TestPickleNestedMessage {
message NestedMessage {
int32 bb = 1;
message NestedNestedMessage {
int32 cc = 1;
}
}
}
message TestMultipleExtensionRanges {
extensions 42;
extensions 4143 to 4243;
extensions 65536 to max;
}
// Test that really large tag numbers don't break anything.
message TestReallyLargeTagNumber {
// The largest possible tag number is 2^28 - 1, since the wire format uses
// three bits to communicate wire type.
int32 a = 1;
int32 bb = 268435455;
}
message TestRecursiveMessage {
TestRecursiveMessage a = 1;
int32 i = 2;
}
// Test that mutual recursion works.
message TestMutualRecursionA {
message SubMessage {
TestMutualRecursionB b = 1;
}
TestMutualRecursionB bb = 1;
message SubGroup {
SubMessage sub_message = 3; // Needed because of bug in javatest
TestAllTypes not_in_this_scc = 4;
}
SubGroup subgroup = 2 [features.message_encoding = DELIMITED];
message SubGroupR {
TestAllTypes payload = 6;
}
repeated SubGroupR subgroupr = 5 [features.message_encoding = DELIMITED];
}
message TestMutualRecursionB {
TestMutualRecursionA a = 1;
int32 optional_int32 = 2;
}
message TestIsInitialized {
message SubMessage {
message SubGroup {
int32 i = 2 [features.field_presence = LEGACY_REQUIRED];
}
SubGroup subgroup = 1 [features.message_encoding = DELIMITED];
}
SubMessage sub_message = 1;
}
// Additional messages for testing lazy fields.
message TestEagerMessage {
TestAllTypes sub_message = 1 [lazy = false];
}
message TestLazyMessage {
TestAllTypes sub_message = 1 [lazy = true];
}
message TestLazyMessageRepeated {
repeated TestLazyMessage repeated_message = 1;
}
message TestEagerMaybeLazy {
message NestedMessage {
TestPackedTypes packed = 1;
}
TestAllTypes message_foo = 1;
TestAllTypes message_bar = 2;
NestedMessage message_baz = 3;
}
// Needed for a Python test.
message TestNestedMessageHasBits {
message NestedMessage {
repeated int32 nestedmessage_repeated_int32 = 1;
repeated ForeignMessage nestedmessage_repeated_foreignmessage = 2;
}
NestedMessage optional_nested_message = 1;
}
// Test an enum that has multiple values with the same number.
enum TestEnumWithDupValue {
option allow_alias = true;
FOO1 = 1;
BAR1 = 2;
BAZ = 3;
FOO2 = 1;
BAR2 = 2;
}
// Test an enum with large, unordered values.
enum TestSparseEnum {
SPARSE_A = 123;
SPARSE_B = 62374;
SPARSE_C = 12589234;
SPARSE_D = -15;
SPARSE_E = -53452;
SPARSE_F = 0;
SPARSE_G = 2;
}
// Test message with CamelCase field names. This violates Protocol Buffer
// standard style.
message TestCamelCaseFieldNames {
int32 PrimitiveField = 1;
string StringField = 2;
ForeignEnum EnumField = 3;
ForeignMessage MessageField = 4;
string StringPieceField = 5 [ctype = STRING_PIECE];
string CordField = 6 [ctype = CORD];
repeated int32 RepeatedPrimitiveField = 7;
repeated string RepeatedStringField = 8;
repeated ForeignEnum RepeatedEnumField = 9;
repeated ForeignMessage RepeatedMessageField = 10;
repeated string RepeatedStringPieceField = 11 [ctype = STRING_PIECE];
repeated string RepeatedCordField = 12 [ctype = CORD];
}
// We list fields out of order, to ensure that we're using field number and not
// field index to determine serialization order.
message TestFieldOrderings {
string my_string = 11;
extensions 2 to 10;
int64 my_int = 1;
extensions 12 to 100;
float my_float = 101;
message NestedMessage {
int64 oo = 2;
// The field name "b" fails to compile in proto1 because it conflicts with
// a local variable named "b" in one of the generated methods. Doh.
// This file needs to compile in proto1 to test backwards-compatibility.
int32 bb = 1;
}
NestedMessage optional_nested_message = 200;
}
extend TestFieldOrderings {
string my_extension_string = 50;
int32 my_extension_int = 5;
}
message TestExtensionOrderings1 {
extend TestFieldOrderings {
TestExtensionOrderings1 test_ext_orderings1 = 13;
}
string my_string = 1;
}
message TestExtensionOrderings2 {
extend TestFieldOrderings {
TestExtensionOrderings2 test_ext_orderings2 = 12;
}
message TestExtensionOrderings3 {
extend TestFieldOrderings {
TestExtensionOrderings3 test_ext_orderings3 = 14;
}
string my_string = 1;
}
string my_string = 1;
}
message TestExtremeDefaultValues {
bytes escaped_bytes = 1 [default = "\0\001\a\b\f\n\r\t\v\\\'\"\xfe"];
uint32 large_uint32 = 2 [default = 0xFFFFFFFF];
uint64 large_uint64 = 3 [default = 0xFFFFFFFFFFFFFFFF];
int32 small_int32 = 4 [default = -0x7FFFFFFF];
int64 small_int64 = 5 [default = -0x7FFFFFFFFFFFFFFF];
int32 really_small_int32 = 21 [default = -0x80000000];
int64 really_small_int64 = 22 [default = -0x8000000000000000];
// The default value here is UTF-8 for "\u1234". (We could also just type
// the UTF-8 text directly into this text file rather than escape it, but
// lots of people use editors that would be confused by this.)
string utf8_string = 6 [default = "\341\210\264"];
// Tests for single-precision floating-point values.
float zero_float = 7 [default = 0];
float one_float = 8 [default = 1];
float small_float = 9 [default = 1.5];
float negative_one_float = 10 [default = -1];
float negative_float = 11 [default = -1.5];
// Using exponents
float large_float = 12 [default = 2e8];
float small_negative_float = 13 [default = -8e-28];
// Text for nonfinite floating-point values.
double inf_double = 14 [default = inf];
double neg_inf_double = 15 [default = -inf];
double nan_double = 16 [default = nan];
float inf_float = 17 [default = inf];
float neg_inf_float = 18 [default = -inf];
float nan_float = 19 [default = nan];
// Tests for C++ trigraphs.
// Trigraphs should be escaped in C++ generated files, but they should not be
// escaped for other languages.
// Note that in .proto file, "\?" is a valid way to escape ? in string
// literals.
string cpp_trigraph = 20 [default = "? \? ?? \?? \??? ??/ ?\?-"];
// String defaults containing the character '\000'
string string_with_zero = 23 [default = "hel\000lo"];
bytes bytes_with_zero = 24 [default = "wor\000ld"];
string string_piece_with_zero = 25
[ctype = STRING_PIECE, default = "ab\000c"];
string cord_with_zero = 26 [ctype = CORD, default = "12\0003"];
string replacement_string = 27 [default = "${unknown}"];
}
message SparseEnumMessage {
TestSparseEnum sparse_enum = 1;
}
// Test String and Bytes: string is for valid UTF-8 strings
message OneString {
string data = 1;
}
message MoreString {
repeated string data = 1;
}
message OneBytes {
bytes data = 1;
}
message MoreBytes {
repeated bytes data = 1;
}
message ManyOptionalString {
string str1 = 1;
string str2 = 2;
string str3 = 3;
string str4 = 4;
string str5 = 5;
string str6 = 6;
string str7 = 7;
string str8 = 8;
string str9 = 9;
string str10 = 10;
string str11 = 11;
string str12 = 12;
string str13 = 13;
string str14 = 14;
string str15 = 15;
string str16 = 16;
string str17 = 17;
string str18 = 18;
string str19 = 19;
string str20 = 20;
string str21 = 21;
string str22 = 22;
string str23 = 23;
string str24 = 24;
string str25 = 25;
string str26 = 26;
string str27 = 27;
string str28 = 28;
string str29 = 29;
string str30 = 30;
string str31 = 31;
string str32 = 32;
}
// Test int32, uint32, int64, uint64, and bool are all compatible
message Int32Message {
int32 data = 1;
}
message Uint32Message {
uint32 data = 1;
}
message Int64Message {
int64 data = 1;
}
message Uint64Message {
uint64 data = 1;
}
message BoolMessage {
bool data = 1;
}
// Test oneofs.
message TestOneof {
oneof foo {
int32 foo_int = 1;
string foo_string = 2;
TestAllTypes foo_message = 3;
FooGroup foogroup = 4 [features.message_encoding = DELIMITED];
}
message FooGroup {
int32 a = 5;
string b = 6;
}
}
message TestOneofBackwardsCompatible {
int32 foo_int = 1;
string foo_string = 2;
TestAllTypes foo_message = 3;
message FooGroup {
int32 a = 5;
string b = 6;
}
FooGroup foogroup = 4 [features.message_encoding = DELIMITED];
}
message TestOneof2 {
oneof foo {
int32 foo_int = 1;
string foo_string = 2;
string foo_cord = 3 [ctype = CORD];
string foo_string_piece = 4 [ctype = STRING_PIECE];
bytes foo_bytes = 5;
NestedEnum foo_enum = 6;
NestedMessage foo_message = 7;
FooGroup foogroup = 8 [features.message_encoding = DELIMITED];
NestedMessage foo_lazy_message = 11 [lazy = true];
bytes foo_bytes_cord = 30 [ctype = CORD];
}
message FooGroup {
int32 a = 9;
string b = 10;
}
oneof bar {
int32 bar_int = 12 [default = 5];
string bar_string = 13 [default = "STRING"];
string bar_cord = 14 [ctype = CORD, default = "CORD"];
string bar_string_piece = 15 [ctype = STRING_PIECE, default = "SPIECE"];
bytes bar_bytes = 16 [default = "BYTES"];
NestedEnum bar_enum = 17 [default = BAR];
string bar_string_with_empty_default = 20 [default = ""];
string bar_cord_with_empty_default = 21 [ctype = CORD, default = ""];
string bar_string_piece_with_empty_default = 22
[ctype = STRING_PIECE, default = ""];
bytes bar_bytes_with_empty_default = 23 [default = ""];
}
int32 baz_int = 18;
string baz_string = 19 [default = "BAZ"];
message NestedMessage {
int64 moo_int = 1;
repeated int32 corge_int = 2;
NestedMessage child = 3;
}
enum NestedEnum {
FOO = 1;
BAR = 2;
BAZ = 3;
}
}
message TestRequiredOneof {
oneof foo {
int32 foo_int = 1;
string foo_string = 2;
NestedMessage foo_message = 3;
NestedMessage foo_lazy_message = 4 [lazy = true];
}
message NestedMessage {
double required_double = 1 [features.field_presence = LEGACY_REQUIRED];
}
}
// Test messages for packed fields
message TestPackedTypes {
repeated int32 packed_int32 = 90 [features.repeated_field_encoding = PACKED];
repeated int64 packed_int64 = 91 [features.repeated_field_encoding = PACKED];
repeated uint32 packed_uint32 = 92
[features.repeated_field_encoding = PACKED];
repeated uint64 packed_uint64 = 93
[features.repeated_field_encoding = PACKED];
repeated sint32 packed_sint32 = 94
[features.repeated_field_encoding = PACKED];
repeated sint64 packed_sint64 = 95
[features.repeated_field_encoding = PACKED];
repeated fixed32 packed_fixed32 = 96
[features.repeated_field_encoding = PACKED];
repeated fixed64 packed_fixed64 = 97
[features.repeated_field_encoding = PACKED];
repeated sfixed32 packed_sfixed32 = 98
[features.repeated_field_encoding = PACKED];
repeated sfixed64 packed_sfixed64 = 99
[features.repeated_field_encoding = PACKED];
repeated float packed_float = 100 [features.repeated_field_encoding = PACKED];
repeated double packed_double = 101
[features.repeated_field_encoding = PACKED];
repeated bool packed_bool = 102 [features.repeated_field_encoding = PACKED];
repeated ForeignEnum packed_enum = 103
[features.repeated_field_encoding = PACKED];
}
// A message with the same fields as TestPackedTypes, but without packing. Used
// to test packed <-> unpacked wire compatibility.
message TestUnpackedTypes {
repeated int32 unpacked_int32 = 90;
repeated int64 unpacked_int64 = 91;
repeated uint32 unpacked_uint32 = 92;
repeated uint64 unpacked_uint64 = 93;
repeated sint32 unpacked_sint32 = 94;
repeated sint64 unpacked_sint64 = 95;
repeated fixed32 unpacked_fixed32 = 96;
repeated fixed64 unpacked_fixed64 = 97;
repeated sfixed32 unpacked_sfixed32 = 98;
repeated sfixed64 unpacked_sfixed64 = 99;
repeated float unpacked_float = 100;
repeated double unpacked_double = 101;
repeated bool unpacked_bool = 102;
repeated ForeignEnum unpacked_enum = 103;
}
message TestPackedExtensions {
extensions 1 to max;
}
extend TestPackedExtensions {
repeated int32 packed_int32_extension = 90
[features.repeated_field_encoding = PACKED];
repeated int64 packed_int64_extension = 91
[features.repeated_field_encoding = PACKED];
repeated uint32 packed_uint32_extension = 92
[features.repeated_field_encoding = PACKED];
repeated uint64 packed_uint64_extension = 93
[features.repeated_field_encoding = PACKED];
repeated sint32 packed_sint32_extension = 94
[features.repeated_field_encoding = PACKED];
repeated sint64 packed_sint64_extension = 95
[features.repeated_field_encoding = PACKED];
repeated fixed32 packed_fixed32_extension = 96
[features.repeated_field_encoding = PACKED];
repeated fixed64 packed_fixed64_extension = 97
[features.repeated_field_encoding = PACKED];
repeated sfixed32 packed_sfixed32_extension = 98
[features.repeated_field_encoding = PACKED];
repeated sfixed64 packed_sfixed64_extension = 99
[features.repeated_field_encoding = PACKED];
repeated float packed_float_extension = 100
[features.repeated_field_encoding = PACKED];
repeated double packed_double_extension = 101
[features.repeated_field_encoding = PACKED];
repeated bool packed_bool_extension = 102
[features.repeated_field_encoding = PACKED];
repeated ForeignEnum packed_enum_extension = 103
[features.repeated_field_encoding = PACKED];
}
message TestUnpackedExtensions {
extensions 1 to max;
}
extend TestUnpackedExtensions {
repeated int32 unpacked_int32_extension = 90;
repeated int64 unpacked_int64_extension = 91;
repeated uint32 unpacked_uint32_extension = 92;
repeated uint64 unpacked_uint64_extension = 93;
repeated sint32 unpacked_sint32_extension = 94;
repeated sint64 unpacked_sint64_extension = 95;
repeated fixed32 unpacked_fixed32_extension = 96;
repeated fixed64 unpacked_fixed64_extension = 97;
repeated sfixed32 unpacked_sfixed32_extension = 98;
repeated sfixed64 unpacked_sfixed64_extension = 99;
repeated float unpacked_float_extension = 100;
repeated double unpacked_double_extension = 101;
repeated bool unpacked_bool_extension = 102;
repeated ForeignEnum unpacked_enum_extension = 103;
}
// Used by ExtensionSetTest/DynamicExtensions. The test actually builds
// a set of extensions to TestAllExtensions dynamically, based on the fields
// of this message type.
message TestDynamicExtensions {
enum DynamicEnumType {
DYNAMIC_FOO = 2200;
DYNAMIC_BAR = 2201;
DYNAMIC_BAZ = 2202;
}
message DynamicMessageType {
int32 dynamic_field = 2100;
}
fixed32 scalar_extension = 2000;
ForeignEnum enum_extension = 2001;
DynamicEnumType dynamic_enum_extension = 2002;
ForeignMessage message_extension = 2003;
DynamicMessageType dynamic_message_extension = 2004;
repeated string repeated_extension = 2005;
repeated sint32 packed_extension = 2006
[features.repeated_field_encoding = PACKED];
}
message TestRepeatedString {
repeated string repeated_string1 = 1;
repeated string repeated_string2 = 2;
repeated bytes repeated_bytes11 = 11;
repeated bytes repeated_bytes12 = 12;
}
message TestRepeatedScalarDifferentTagSizes {
// Parsing repeated fixed size values used to fail. This message needs to be
// used in order to get a tag of the right size; all of the repeated fields
// in TestAllTypes didn't trigger the check.
repeated fixed32 repeated_fixed32 = 12;
// Check for a varint type, just for good measure.
repeated int32 repeated_int32 = 13;
// These have two-byte tags.
repeated fixed64 repeated_fixed64 = 2046;
repeated int64 repeated_int64 = 2047;
// Three byte tags.
repeated float repeated_float = 262142;
repeated uint64 repeated_uint64 = 262143;
}
// Test that if an optional or required message/group field appears multiple
// times in the input, they need to be merged.
message TestParsingMerge {
// RepeatedFieldsGenerator defines matching field types as TestParsingMerge,
// except that all fields are repeated. In the tests, we will serialize the
// RepeatedFieldsGenerator to bytes, and parse the bytes to TestParsingMerge.
// Repeated fields in RepeatedFieldsGenerator are expected to be merged into
// the corresponding required/optional fields in TestParsingMerge.
message RepeatedFieldsGenerator {
repeated TestAllTypes field1 = 1;
repeated TestAllTypes field2 = 2;
repeated TestAllTypes field3 = 3;
message Group1 {
TestAllTypes field1 = 11;
}
repeated Group1 group1 = 10 [features.message_encoding = DELIMITED];
message Group2 {
TestAllTypes field1 = 21;
}
repeated Group2 group2 = 20 [features.message_encoding = DELIMITED];
repeated TestAllTypes ext1 = 1000;
repeated TestAllTypes ext2 = 1001;
}
TestAllTypes required_all_types = 1
[features.field_presence = LEGACY_REQUIRED];
TestAllTypes optional_all_types = 2;
repeated TestAllTypes repeated_all_types = 3;
message OptionalGroup {
TestAllTypes optional_group_all_types = 11;
}
OptionalGroup optionalgroup = 10 [features.message_encoding = DELIMITED];
message RepeatedGroup {
TestAllTypes repeated_group_all_types = 21;
}
repeated RepeatedGroup repeatedgroup = 20
[features.message_encoding = DELIMITED];
extensions 1000 to max;
extend TestParsingMerge {
TestAllTypes optional_ext = 1000;
repeated TestAllTypes repeated_ext = 1001;
}
}
// Test that the correct exception is thrown by parseFrom in a corner case
// involving merging, extensions, and required fields.
message TestMergeException {
TestAllExtensions all_extensions = 1;
}
message TestCommentInjectionMessage {
// */ <- This should not close the generated doc comment
string a = 1 [default = "*/ <- Neither should this."];
}
// Used to check that the c++ code generator re-orders messages to reduce
// padding.
message TestMessageSize {
bool m1 = 1;
int64 m2 = 2;
bool m3 = 3;
string m4 = 4;
int32 m5 = 5;
int64 m6 = 6;
}
message OpenEnumMessage {
enum TestEnum {
option features.enum_type = OPEN;
UNKNOWN = 0;
FOO = 1;
BAR = 2;
BAZ = 3;
}
TestEnum opt_open = 1;
ForeignEnum opt_closed = 2;
repeated TestEnum repeated_open = 3;
repeated ForeignEnum repeated_closed = 4;
}
// Tests eager verification of a lazy message field.
message TestEagerlyVerifiedLazyMessage {
message LazyMessage {
bytes bytes_field = 1;
}
LazyMessage lazy_message = 1 [lazy = true];
}
message TestJsonName {
int32 field_name1 = 1;
int32 fieldName2 = 2;
int32 FieldName3 = 3;
int32 _field_name4 = 4;
int32 FIELD_NAME5 = 5;
int32 field_name6 = 6 [json_name = "@type"];
int32 fieldname7 = 7;
}
message TestHugeFieldNumbers {
int32 optional_int32 = 536870000;
int32 fixed_32 = 536870001;
repeated int32 repeated_int32 = 536870002;
repeated int32 packed_int32 = 536870003
[features.repeated_field_encoding = PACKED];
ForeignEnum optional_enum = 536870004;
string optional_string = 536870005;
bytes optional_bytes = 536870006;
ForeignMessage optional_message = 536870007;
message OptionalGroup {
int32 group_a = 536870009;
}
OptionalGroup optionalgroup = 536870008
[features.message_encoding = DELIMITED];
map<string, string> string_string_map = 536870010;
oneof oneof_field {
uint32 oneof_uint32 = 536870011;
TestAllTypes oneof_test_all_types = 536870012;
string oneof_string = 536870013;
bytes oneof_bytes = 536870014;
}
extensions 536860000 to 536869999 [declaration = {
number: 536860000
full_name: ".rust_unittest.test_all_types"
type: ".rust_unittest.TestAllTypes"
}];
}
extend TestHugeFieldNumbers {
TestAllTypes test_all_types = 536860000;
}
message TestExtensionInsideTable {
int32 field1 = 1;
int32 field2 = 2;
int32 field3 = 3;
int32 field4 = 4;
extensions 5;
int32 field6 = 6;
int32 field7 = 7;
int32 field8 = 8;
int32 field9 = 9;
int32 field10 = 10;
}
extend TestExtensionInsideTable {
int32 test_extension_inside_table_extension = 5;
}
// NOTE: Intentionally nested to mirror go/glep.
message TestNestedGroupExtensionOuter {
message Layer1OptionalGroup {
message Layer2RepeatedGroup {
extensions 3
// NOTE: extension metadata is not supported due to targets such as
// `//google/protobuf_legacy_opensource/src:shell_scripts_test`,
// eee https://screenshot.googleplex.com/Axz2QD8nxjdpyFF
// [metadata = {
// NOTE: can't write type there due to some clever build gen code at
// http://google3/google/protobuf/BUILD;l=1247;rcl=411090862
// type: "rust_unittest.TestNestedGroupExtensionInnerExtension",
// name: "inner",
// }]
;
string another_field = 6;
}
repeated Layer2RepeatedGroup layer2repeatedgroup = 2
[features.message_encoding = DELIMITED];
message Layer2AnotherOptionalRepeatedGroup {
string but_why_tho = 5;
}
repeated Layer2AnotherOptionalRepeatedGroup
layer2anotheroptionalrepeatedgroup = 4
[features.message_encoding = DELIMITED];
}
Layer1OptionalGroup layer1optionalgroup = 1
[features.message_encoding = DELIMITED];
}
message TestNestedGroupExtensionInnerExtension {
string inner_name = 1;
}
extend TestNestedGroupExtensionOuter.Layer1OptionalGroup.Layer2RepeatedGroup {
TestNestedGroupExtensionInnerExtension inner = 3;
}
enum VeryLargeEnum {
ENUM_LABEL_DEFAULT = 0;
ENUM_LABEL_1 = 1;
ENUM_LABEL_2 = 2;
ENUM_LABEL_3 = 3;
ENUM_LABEL_4 = 4;
ENUM_LABEL_5 = 5;
ENUM_LABEL_6 = 6;
ENUM_LABEL_7 = 7;
ENUM_LABEL_8 = 8;
ENUM_LABEL_9 = 9;
ENUM_LABEL_10 = 10;
ENUM_LABEL_11 = 11;
ENUM_LABEL_12 = 12;
ENUM_LABEL_13 = 13;
ENUM_LABEL_14 = 14;
ENUM_LABEL_15 = 15;
ENUM_LABEL_16 = 16;
ENUM_LABEL_17 = 17;
ENUM_LABEL_18 = 18;
ENUM_LABEL_19 = 19;
ENUM_LABEL_20 = 20;
ENUM_LABEL_21 = 21;
ENUM_LABEL_22 = 22;
ENUM_LABEL_23 = 23;
ENUM_LABEL_24 = 24;
ENUM_LABEL_25 = 25;
ENUM_LABEL_26 = 26;
ENUM_LABEL_27 = 27;
ENUM_LABEL_28 = 28;
ENUM_LABEL_29 = 29;
ENUM_LABEL_30 = 30;
ENUM_LABEL_31 = 31;
ENUM_LABEL_32 = 32;
ENUM_LABEL_33 = 33;
ENUM_LABEL_34 = 34;
ENUM_LABEL_35 = 35;
ENUM_LABEL_36 = 36;
ENUM_LABEL_37 = 37;
ENUM_LABEL_38 = 38;
ENUM_LABEL_39 = 39;
ENUM_LABEL_40 = 40;
ENUM_LABEL_41 = 41;
ENUM_LABEL_42 = 42;
ENUM_LABEL_43 = 43;
ENUM_LABEL_44 = 44;
ENUM_LABEL_45 = 45;
ENUM_LABEL_46 = 46;
ENUM_LABEL_47 = 47;
ENUM_LABEL_48 = 48;
ENUM_LABEL_49 = 49;
ENUM_LABEL_50 = 50;
ENUM_LABEL_51 = 51;
ENUM_LABEL_52 = 52;
ENUM_LABEL_53 = 53;
ENUM_LABEL_54 = 54;
ENUM_LABEL_55 = 55;
ENUM_LABEL_56 = 56;
ENUM_LABEL_57 = 57;
ENUM_LABEL_58 = 58;
ENUM_LABEL_59 = 59;
ENUM_LABEL_60 = 60;
ENUM_LABEL_61 = 61;
ENUM_LABEL_62 = 62;
ENUM_LABEL_63 = 63;
ENUM_LABEL_64 = 64;
ENUM_LABEL_65 = 65;
ENUM_LABEL_66 = 66;
ENUM_LABEL_67 = 67;
ENUM_LABEL_68 = 68;
ENUM_LABEL_69 = 69;
ENUM_LABEL_70 = 70;
ENUM_LABEL_71 = 71;
ENUM_LABEL_72 = 72;
ENUM_LABEL_73 = 73;
ENUM_LABEL_74 = 74;
ENUM_LABEL_75 = 75;
ENUM_LABEL_76 = 76;
ENUM_LABEL_77 = 77;
ENUM_LABEL_78 = 78;
ENUM_LABEL_79 = 79;
ENUM_LABEL_80 = 80;
ENUM_LABEL_81 = 81;
ENUM_LABEL_82 = 82;
ENUM_LABEL_83 = 83;
ENUM_LABEL_84 = 84;
ENUM_LABEL_85 = 85;
ENUM_LABEL_86 = 86;
ENUM_LABEL_87 = 87;
ENUM_LABEL_88 = 88;
ENUM_LABEL_89 = 89;
ENUM_LABEL_90 = 90;
ENUM_LABEL_91 = 91;
ENUM_LABEL_92 = 92;
ENUM_LABEL_93 = 93;
ENUM_LABEL_94 = 94;
ENUM_LABEL_95 = 95;
ENUM_LABEL_96 = 96;
ENUM_LABEL_97 = 97;
ENUM_LABEL_98 = 98;
ENUM_LABEL_99 = 99;
ENUM_LABEL_100 = 100;
}
message TestExtensionRangeSerialize {
int32 foo_one = 1;
extensions 2;
extensions 3 to 4;
int32 foo_two = 6;
int32 foo_three = 7;
extensions 9 to 10;
int32 foo_four = 13;
extensions 15 to 15;
extensions 17 to 17;
extensions 19 to 19;
extend TestExtensionRangeSerialize {
int32 bar_one = 2;
int32 bar_two = 4;
int32 bar_three = 10;
int32 bar_four = 15;
int32 bar_five = 19;
}
}
message TestVerifyInt32Simple {
int32 optional_int32_1 = 1;
int32 optional_int32_2 = 2;
int32 optional_int32_63 = 63;
int32 optional_int32_64 = 64;
}
message TestVerifyInt32 {
int32 optional_int32_1 = 1;
int32 optional_int32_2 = 2;
int32 optional_int32_63 = 63;
int32 optional_int32_64 = 64;
TestAllTypes optional_all_types = 9;
repeated TestAllTypes repeated_all_types = 10;
}
message TestVerifyMostlyInt32 {
int64 optional_int64_30 = 30;
int32 optional_int32_1 = 1;
int32 optional_int32_2 = 2;
int32 optional_int32_3 = 3;
int32 optional_int32_4 = 4;
int32 optional_int32_63 = 63;
int32 optional_int32_64 = 64;
TestAllTypes optional_all_types = 9;
repeated TestAllTypes repeated_all_types = 10;
}
message TestVerifyMostlyInt32BigFieldNumber {
int64 optional_int64_30 = 30;
int32 optional_int32_300 = 300;
int32 optional_int32_1 = 1;
int32 optional_int32_2 = 2;
int32 optional_int32_3 = 3;
int32 optional_int32_4 = 4;
int32 optional_int32_63 = 63;
int32 optional_int32_64 = 64;
TestAllTypes optional_all_types = 9;
repeated TestAllTypes repeated_all_types = 10;
}
message TestVerifyUint32Simple {
uint32 optional_uint32_1 = 1;
uint32 optional_uint32_2 = 2;
uint32 optional_uint32_63 = 63;
uint32 optional_uint32_64 = 64;
}
message TestVerifyUint32 {
uint32 optional_uint32_1 = 1;
uint32 optional_uint32_2 = 2;
uint32 optional_uint32_63 = 63;
uint32 optional_uint32_64 = 64;
TestAllTypes optional_all_types = 9;
repeated TestAllTypes repeated_all_types = 10;
}
message TestVerifyOneUint32 {
uint32 optional_uint32_1 = 1;
int32 optional_int32_2 = 2;
int32 optional_int32_63 = 63;
int32 optional_int32_64 = 64;
TestAllTypes optional_all_types = 9;
repeated TestAllTypes repeated_all_types = 10;
}
message TestVerifyOneInt32BigFieldNumber {
int32 optional_int32_65 = 65;
int64 optional_int64_1 = 1;
int64 optional_int64_2 = 2;
int64 optional_int64_63 = 63;
int64 optional_int64_64 = 64;
TestAllTypes optional_all_types = 9;
repeated TestAllTypes repeated_all_types = 10;
}
message TestVerifyInt32BigFieldNumber {
int32 optional_int32_1000 = 1000;
int32 optional_int32_65 = 65;
int32 optional_int32_1 = 1;
int32 optional_int32_2 = 2;
int32 optional_int32_63 = 63;
int32 optional_int32_64 = 64;
TestAllTypes optional_all_types = 9;
repeated TestAllTypes repeated_all_types = 10;
}
message TestVerifyUint32BigFieldNumber {
uint32 optional_uint32_1000 = 1000;
uint32 optional_uint32_65 = 65;
uint32 optional_uint32_1 = 1;
uint32 optional_uint32_2 = 2;
uint32 optional_uint32_63 = 63;
uint32 optional_uint32_64 = 64;
TestAllTypes optional_all_types = 9;
repeated TestAllTypes repeated_all_types = 10;
}
message TestVerifyBigFieldNumberUint32 {
message Nested {
uint32 optional_uint32_5000 = 5000;
uint32 optional_uint32_1000 = 1000;
uint32 optional_uint32_66 = 66;
uint32 optional_uint32_65 = 65;
uint32 optional_uint32_1 = 1;
uint32 optional_uint32_2 = 2;
uint32 optional_uint32_63 = 63;
uint32 optional_uint32_64 = 64;
Nested optional_nested = 9;
repeated Nested repeated_nested = 10;
}
Nested optional_nested = 1;
}
message TestVerify {
message Nested {
int32 required_int32_64 = 64 [features.field_presence = LEGACY_REQUIRED];
uint32 required_uint32_63 = 63 [features.field_presence = LEGACY_REQUIRED];
uint32 required_uint32_30 = 30 [features.field_presence = LEGACY_REQUIRED];
uint32 optional_uint32_8 = 8;
uint32 optional_uint32_7 = 7;
uint32 optional_uint32_5 = 5;
uint32 optional_uint32_4 = 4;
uint32 optional_uint32_1 = 1;
repeated uint32 packed_uint32_2 = 2
[features.repeated_field_encoding = PACKED];
int32 optional_int32_6 = 6;
int32 optional_int32_3 = 3;
Nested optional_nested = 9;
repeated Nested repeated_nested = 10;
}
message NestedBigFieldNumber {
int32 required_int32_80 = 80 [features.field_presence = LEGACY_REQUIRED];
uint32 optional_uint32_8 = 8;
uint32 optional_uint32_7 = 7;
uint32 required_uint32_1 = 1 [features.field_presence = LEGACY_REQUIRED];
}
Nested optional_nested = 1;
NestedBigFieldNumber optional_nested_big_field = 2;
}
message TestVerifyBigFieldNumber {
message Nested {
int32 optional_int32_5000 = 5000;
int32 optional_int32_1000 = 1000;
int32 optional_int32_66 = 66;
int32 optional_int32_65 = 65;
int32 optional_int32_1 = 1;
uint32 optional_uint32_2 = 2;
uint32 optional_uint32_63 = 63;
int32 optional_int32_64 = 64;
Nested optional_nested = 9;
repeated Nested repeated_nested = 10;
}
Nested optional_nested = 1;
}
message TestSplitFields {
int32 optional_int32_1 = 1;
int32 optional_int32_2 = 2;
int32 optional_int32_3 = 3;
int32 optional_int32_4 = 4;
int32 optional_int32_5 = 5;
int32 optional_int32_6 = 6;
int32 optional_int32_7 = 7;
int32 optional_int32_8 = 8;
repeated int32 repeated_int32_1 = 9;
repeated int32 repeated_int32_2 = 10;
repeated int32 repeated_int32_3 = 11;
repeated int32 repeated_int32_4 = 12;
repeated int32 repeated_int32_5 = 13;
repeated int32 repeated_int32_6 = 14;
repeated int32 repeated_int32_7 = 15;
repeated int32 repeated_int32_8 = 16;
}
message BadFieldNames {
int32 OptionalInt32 = 1;
int32 for = 2;
}
message TestNestedMessageRedaction {
string optional_unredacted_nested_string = 1;
string optional_redacted_nested_string = 2 [debug_redact = true];
}
message RedactedFields {
string optional_redacted_string = 1 [debug_redact = true];
string optional_unredacted_string = 2;
repeated string repeated_redacted_string = 3 [debug_redact = true];
repeated string repeated_unredacted_string = 4;
TestNestedMessageRedaction optional_redacted_message = 5
[debug_redact = true];
TestNestedMessageRedaction optional_unredacted_message = 6;
repeated TestNestedMessageRedaction repeated_redacted_message = 7
[debug_redact = true];
repeated TestNestedMessageRedaction repeated_unredacted_message = 8;
map<string, string> map_redacted_string = 9 [debug_redact = true];
map<string, string> map_unredacted_string = 10;
string optional_redacted_false_string = 11 [debug_redact = false];
extensions 20 to 30;
}
extend RedactedFields {
string redacted_extension = 20 [debug_redact = true];
}
message TestCord {
bytes optional_bytes_cord = 1 [ctype = CORD];
bytes optional_bytes_cord_default = 2 [ctype = CORD, default = "hello"];
}
message TestPackedEnumSmallRange {
enum NestedEnum {
UNSPECIFIED = 0;
FOO = 1;
BAR = 2;
BAZ = 3;
}
repeated NestedEnum vals = 1 [features.repeated_field_encoding = PACKED];
}
message EnumsForBenchmark {
enum Flat {
A0 = 0;
A1 = 1;
A2 = 2;
A3 = 3;
A4 = 4;
A5 = 5;
A6 = 6;
A7 = 7;
A8 = 8;
A9 = 9;
A10 = 10;
A11 = 11;
A12 = 12;
A13 = 13;
A14 = 14;
A15 = 15;
}
// Has a few holes, bitmap can be used.
enum AlmostFlat {
B0 = 0;
B1 = 1;
B2 = 2;
B3 = 3;
B5 = 5;
B6 = 6;
B7 = 7;
B8 = 8;
B9 = 9;
B11 = 11;
B12 = 12;
B13 = 13;
B14 = 14;
B15 = 15;
B17 = 17;
B19 = 19;
}
enum Sparse {
C536 = 536;
C8387 = 8387;
C9673 = 9673;
C10285 = 10285;
C13318 = 13318;
C15963 = 15963;
C16439 = 16439;
C18197 = 18197;
C19430 = 19430;
C20361 = 20361;
C20706 = 20706;
C21050 = 21050;
C21906 = 21906;
C27265 = 27265;
C30109 = 30109;
C31670 = 31670;
}
}
message TestMessageWithManyRepeatedPtrFields {
repeated string repeated_string_1 = 1;
repeated string repeated_string_2 = 2;
repeated string repeated_string_3 = 3;
repeated string repeated_string_4 = 4;
repeated string repeated_string_5 = 5;
repeated string repeated_string_6 = 6;
repeated string repeated_string_7 = 7;
repeated string repeated_string_8 = 8;
repeated string repeated_string_9 = 9;
repeated string repeated_string_10 = 10;
repeated string repeated_string_11 = 11;
repeated string repeated_string_12 = 12;
repeated string repeated_string_13 = 13;
repeated string repeated_string_14 = 14;
repeated string repeated_string_15 = 15;
repeated string repeated_string_16 = 16;
repeated string repeated_string_17 = 17;
repeated string repeated_string_18 = 18;
repeated string repeated_string_19 = 19;
repeated string repeated_string_20 = 20;
repeated string repeated_string_21 = 21;
repeated string repeated_string_22 = 22;
repeated string repeated_string_23 = 23;
repeated string repeated_string_24 = 24;
repeated string repeated_string_25 = 25;
repeated string repeated_string_26 = 26;
repeated string repeated_string_27 = 27;
repeated string repeated_string_28 = 28;
repeated string repeated_string_29 = 29;
repeated string repeated_string_30 = 30;
repeated string repeated_string_31 = 31;
repeated string repeated_string_32 = 32;
}
|