blob: c2006bd13a10d33564df722b63aac91359cde021 [file] [log] [blame]
Herbie Ongcddf8192018-11-28 18:25:20 -08001// Copyright 2018 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// Test Protobuf definitions with proto3 syntax.
6syntax = "proto3";
7
8package pb3;
Joe Tsai94e730b2020-01-10 23:31:25 -08009option go_package = "google.golang.org/protobuf/internal/testprotos/textpb3";
Herbie Ongcddf8192018-11-28 18:25:20 -080010
11// Scalars contains scalar field types.
12message Scalars {
13 bool s_bool = 1;
Herbie Ongcddf8192018-11-28 18:25:20 -080014 int32 s_int32 = 2;
15 int64 s_int64 = 3;
16 uint32 s_uint32 = 4;
17 uint64 s_uint64 = 5;
18 sint32 s_sint32 = 6;
19 sint64 s_sint64 = 7;
20 fixed32 s_fixed32 = 8;
21 fixed64 s_fixed64 = 9;
22 sfixed32 s_sfixed32 = 10;
23 sfixed64 s_sfixed64 = 11;
24
Herbie Ong800c9902018-12-06 15:28:53 -080025 // Textproto marshal outputs fields in the same order as this proto
26 // definition regardless of field number. Following fields are intended to
27 // test that assumption.
28
Herbie Ongcddf8192018-11-28 18:25:20 -080029 float s_float = 20;
30 double s_double = 21;
31
32 bytes s_bytes = 14;
33 string s_string = 13;
34}
35
36enum Enum {
37 ZERO = 0;
38 ONE = 1;
39 TWO = 2;
40 TEN = 10;
41}
42
43// Message contains enum fields.
44message Enums {
45 Enum s_enum = 1;
Herbie Ongcddf8192018-11-28 18:25:20 -080046
47 enum NestedEnum {
48 CERO = 0;
49 UNO = 1;
50 DOS = 2;
51 DIEZ = 10;
52 }
53 NestedEnum s_nested_enum = 3;
Herbie Ongcddf8192018-11-28 18:25:20 -080054}
55
Herbie Ong800c9902018-12-06 15:28:53 -080056// Message contains nested message field.
Herbie Ongcddf8192018-11-28 18:25:20 -080057message Nests {
Herbie Ong8170d692019-02-13 14:13:21 -080058 Nested s_nested = 2;
Herbie Ongcddf8192018-11-28 18:25:20 -080059}
60
61// Message type used as submessage.
62message Nested {
63 string s_string = 1;
64 Nested s_nested = 2;
65}
Herbie Ong8170d692019-02-13 14:13:21 -080066
67// Message contains oneof field.
68message Oneofs {
69 oneof union {
70 Enum oneof_enum = 1;
71 string oneof_string = 2;
72 Nested oneof_nested = 3;
73 }
74}
75
76// Message contains map fields.
77message Maps {
78 map<int32, string> int32_to_str = 1;
79 map<bool, uint32> bool_to_uint32 = 2;
80 map<uint64, Enum> uint64_to_enum = 3;
81 map<string, Nested> str_to_nested = 4;
82 map<string, Oneofs> str_to_oneofs = 5;
83}
Herbie Ong7b828bc2019-02-08 19:56:24 -080084
85// Message for testing json_name option.
86message JSONNames {
87 string s_string = 1 [json_name = "foo_bar"];
88}