Herbie Ong | cddf819 | 2018-11-28 18:25:20 -0800 | [diff] [blame] | 1 | // 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. |
| 6 | syntax = "proto3"; |
| 7 | |
| 8 | package pb3; |
| 9 | option go_package = "github.com/golang/protobuf/v2/encoding/textpb/testprotos/pb3"; |
| 10 | |
| 11 | // Scalars contains scalar field types. |
| 12 | message Scalars { |
| 13 | bool s_bool = 1; |
| 14 | |
| 15 | int32 s_int32 = 2; |
| 16 | int64 s_int64 = 3; |
| 17 | uint32 s_uint32 = 4; |
| 18 | uint64 s_uint64 = 5; |
| 19 | sint32 s_sint32 = 6; |
| 20 | sint64 s_sint64 = 7; |
| 21 | fixed32 s_fixed32 = 8; |
| 22 | fixed64 s_fixed64 = 9; |
| 23 | sfixed32 s_sfixed32 = 10; |
| 24 | sfixed64 s_sfixed64 = 11; |
| 25 | |
Herbie Ong | 800c990 | 2018-12-06 15:28:53 -0800 | [diff] [blame^] | 26 | // Textproto marshal outputs fields in the same order as this proto |
| 27 | // definition regardless of field number. Following fields are intended to |
| 28 | // test that assumption. |
| 29 | |
Herbie Ong | cddf819 | 2018-11-28 18:25:20 -0800 | [diff] [blame] | 30 | float s_float = 20; |
| 31 | double s_double = 21; |
| 32 | |
| 33 | bytes s_bytes = 14; |
| 34 | string s_string = 13; |
| 35 | } |
| 36 | |
| 37 | enum Enum { |
| 38 | ZERO = 0; |
| 39 | ONE = 1; |
| 40 | TWO = 2; |
| 41 | TEN = 10; |
| 42 | } |
| 43 | |
| 44 | // Message contains enum fields. |
| 45 | message Enums { |
| 46 | Enum s_enum = 1; |
Herbie Ong | cddf819 | 2018-11-28 18:25:20 -0800 | [diff] [blame] | 47 | |
| 48 | enum NestedEnum { |
| 49 | CERO = 0; |
| 50 | UNO = 1; |
| 51 | DOS = 2; |
| 52 | DIEZ = 10; |
| 53 | } |
| 54 | NestedEnum s_nested_enum = 3; |
Herbie Ong | cddf819 | 2018-11-28 18:25:20 -0800 | [diff] [blame] | 55 | } |
| 56 | |
Herbie Ong | 800c990 | 2018-12-06 15:28:53 -0800 | [diff] [blame^] | 57 | // Message contains nested message field. |
Herbie Ong | cddf819 | 2018-11-28 18:25:20 -0800 | [diff] [blame] | 58 | message Nests { |
| 59 | Nested s_nested = 1; |
Herbie Ong | cddf819 | 2018-11-28 18:25:20 -0800 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | // Message type used as submessage. |
| 63 | message Nested { |
| 64 | string s_string = 1; |
| 65 | Nested s_nested = 2; |
| 66 | } |