| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| 11 // * Redistributions in binary form must reproduce the above | 11 // * Redistributions in binary form must reproduce the above |
| 12 // copyright notice, this list of conditions and the following disclaimer | 12 // copyright notice, this list of conditions and the following disclaimer |
| 13 // in the documentation and/or other materials provided with the | 13 // in the documentation and/or other materials provided with the |
| 14 // distribution. | 14 // distribution. |
| 15 // * Neither the name of Google Inc. nor the names of its | 15 // * Neither the name of Google Inc. nor the names of its |
| 16 // contributors may be used to endorse or promote products derived from | 16 // contributors may be used to endorse or promote products derived from |
| 17 // this software without specific prior written permission. | 17 // this software without specific prior written permission. |
| 18 // | 18 // |
| 19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 // |
| 31 // Test schema for proto3 messages. This test schema is used by: |
| 32 // |
| 33 // - benchmarks |
| 34 // - fuzz tests |
| 35 // - conformance tests |
| 36 // |
| 30 | 37 |
| 31 syntax = "proto3"; | 38 syntax = "proto3"; |
| 32 package conformance; | 39 |
| 33 option java_package = "com.google.protobuf.conformance"; | 40 package protobuf_test_messages.proto3; |
| 41 option java_package = "com.google.protobuf_test_messages.proto3"; |
| 42 |
| 43 // This is the default, but we specify it here explicitly. |
| 44 option optimize_for = SPEED; |
| 34 | 45 |
| 35 import "google/protobuf/any.proto"; | 46 import "google/protobuf/any.proto"; |
| 36 import "google/protobuf/duration.proto"; | 47 import "google/protobuf/duration.proto"; |
| 37 import "google/protobuf/field_mask.proto"; | 48 import "google/protobuf/field_mask.proto"; |
| 38 import "google/protobuf/struct.proto"; | 49 import "google/protobuf/struct.proto"; |
| 39 import "google/protobuf/timestamp.proto"; | 50 import "google/protobuf/timestamp.proto"; |
| 40 import "google/protobuf/wrappers.proto"; | 51 import "google/protobuf/wrappers.proto"; |
| 41 | 52 |
| 42 // This defines the conformance testing protocol. This protocol exists between | 53 option cc_enable_arenas = true; |
| 43 // the conformance test suite itself and the code being tested. For each test, | |
| 44 // the suite will send a ConformanceRequest message and expect a | |
| 45 // ConformanceResponse message. | |
| 46 // | |
| 47 // You can either run the tests in two different ways: | |
| 48 // | |
| 49 // 1. in-process (using the interface in conformance_test.h). | |
| 50 // | |
| 51 // 2. as a sub-process communicating over a pipe. Information about how to | |
| 52 // do this is in conformance_test_runner.cc. | |
| 53 // | |
| 54 // Pros/cons of the two approaches: | |
| 55 // | |
| 56 // - running as a sub-process is much simpler for languages other than C/C++. | |
| 57 // | |
| 58 // - running as a sub-process may be more tricky in unusual environments like | |
| 59 // iOS apps, where fork/stdin/stdout are not available. | |
| 60 | |
| 61 enum WireFormat { | |
| 62 UNSPECIFIED = 0; | |
| 63 PROTOBUF = 1; | |
| 64 JSON = 2; | |
| 65 } | |
| 66 | |
| 67 // Represents a single test case's input. The testee should: | |
| 68 // | |
| 69 // 1. parse this proto (which should always succeed) | |
| 70 // 2. parse the protobuf or JSON payload in "payload" (which may fail) | |
| 71 // 3. if the parse succeeded, serialize the message in the requested format. | |
| 72 message ConformanceRequest { | |
| 73 // The payload (whether protobuf of JSON) is always for a TestAllTypes proto | |
| 74 // (see below). | |
| 75 oneof payload { | |
| 76 bytes protobuf_payload = 1; | |
| 77 string json_payload = 2; | |
| 78 } | |
| 79 | |
| 80 // Which format should the testee serialize its message to? | |
| 81 WireFormat requested_output_format = 3; | |
| 82 } | |
| 83 | |
| 84 // Represents a single test case's output. | |
| 85 message ConformanceResponse { | |
| 86 oneof result { | |
| 87 // This string should be set to indicate parsing failed. The string can | |
| 88 // provide more information about the parse error if it is available. | |
| 89 // | |
| 90 // Setting this string does not necessarily mean the testee failed the | |
| 91 // test. Some of the test cases are intentionally invalid input. | |
| 92 string parse_error = 1; | |
| 93 | |
| 94 // If the input was successfully parsed but errors occurred when | |
| 95 // serializing it to the requested output format, set the error message in | |
| 96 // this field. | |
| 97 string serialize_error = 6; | |
| 98 | |
| 99 // This should be set if some other error occurred. This will always | |
| 100 // indicate that the test failed. The string can provide more information | |
| 101 // about the failure. | |
| 102 string runtime_error = 2; | |
| 103 | |
| 104 // If the input was successfully parsed and the requested output was | |
| 105 // protobuf, serialize it to protobuf and set it in this field. | |
| 106 bytes protobuf_payload = 3; | |
| 107 | |
| 108 // If the input was successfully parsed and the requested output was JSON, | |
| 109 // serialize to JSON and set it in this field. | |
| 110 string json_payload = 4; | |
| 111 | |
| 112 // For when the testee skipped the test, likely because a certain feature | |
| 113 // wasn't supported, like JSON input/output. | |
| 114 string skipped = 5; | |
| 115 } | |
| 116 } | |
| 117 | 54 |
| 118 // This proto includes every type of field in both singular and repeated | 55 // This proto includes every type of field in both singular and repeated |
| 119 // forms. | 56 // forms. |
| 57 // |
| 58 // Also, crucially, all messages and enums in this file are eventually |
| 59 // submessages of this message. So for example, a fuzz test of TestAllTypes |
| 60 // could trigger bugs that occur in any message type in this file. We verify |
| 61 // this stays true in a unit test. |
| 120 message TestAllTypes { | 62 message TestAllTypes { |
| 121 message NestedMessage { | 63 message NestedMessage { |
| 122 int32 a = 1; | 64 int32 a = 1; |
| 123 TestAllTypes corecursive = 2; | 65 TestAllTypes corecursive = 2; |
| 124 } | 66 } |
| 125 | 67 |
| 126 enum NestedEnum { | 68 enum NestedEnum { |
| 127 FOO = 0; | 69 FOO = 0; |
| 128 BAR = 1; | 70 BAR = 1; |
| 129 BAZ = 2; | 71 BAZ = 2; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 map < string, NestedMessage> map_string_nested_message = 71; | 145 map < string, NestedMessage> map_string_nested_message = 71; |
| 204 map < string, ForeignMessage> map_string_foreign_message = 72; | 146 map < string, ForeignMessage> map_string_foreign_message = 72; |
| 205 map < string, NestedEnum> map_string_nested_enum = 73; | 147 map < string, NestedEnum> map_string_nested_enum = 73; |
| 206 map < string, ForeignEnum> map_string_foreign_enum = 74; | 148 map < string, ForeignEnum> map_string_foreign_enum = 74; |
| 207 | 149 |
| 208 oneof oneof_field { | 150 oneof oneof_field { |
| 209 uint32 oneof_uint32 = 111; | 151 uint32 oneof_uint32 = 111; |
| 210 NestedMessage oneof_nested_message = 112; | 152 NestedMessage oneof_nested_message = 112; |
| 211 string oneof_string = 113; | 153 string oneof_string = 113; |
| 212 bytes oneof_bytes = 114; | 154 bytes oneof_bytes = 114; |
| 155 bool oneof_bool = 115; |
| 156 uint64 oneof_uint64 = 116; |
| 157 float oneof_float = 117; |
| 158 double oneof_double = 118; |
| 159 NestedEnum oneof_enum = 119; |
| 213 } | 160 } |
| 214 | 161 |
| 215 // Well-known types | 162 // Well-known types |
| 216 google.protobuf.BoolValue optional_bool_wrapper = 201; | 163 google.protobuf.BoolValue optional_bool_wrapper = 201; |
| 217 google.protobuf.Int32Value optional_int32_wrapper = 202; | 164 google.protobuf.Int32Value optional_int32_wrapper = 202; |
| 218 google.protobuf.Int64Value optional_int64_wrapper = 203; | 165 google.protobuf.Int64Value optional_int64_wrapper = 203; |
| 219 google.protobuf.UInt32Value optional_uint32_wrapper = 204; | 166 google.protobuf.UInt32Value optional_uint32_wrapper = 204; |
| 220 google.protobuf.UInt64Value optional_uint64_wrapper = 205; | 167 google.protobuf.UInt64Value optional_uint64_wrapper = 205; |
| 221 google.protobuf.FloatValue optional_float_wrapper = 206; | 168 google.protobuf.FloatValue optional_float_wrapper = 206; |
| 222 google.protobuf.DoubleValue optional_double_wrapper = 207; | 169 google.protobuf.DoubleValue optional_double_wrapper = 207; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 241 google.protobuf.Value optional_value = 306; | 188 google.protobuf.Value optional_value = 306; |
| 242 | 189 |
| 243 repeated google.protobuf.Duration repeated_duration = 311; | 190 repeated google.protobuf.Duration repeated_duration = 311; |
| 244 repeated google.protobuf.Timestamp repeated_timestamp = 312; | 191 repeated google.protobuf.Timestamp repeated_timestamp = 312; |
| 245 repeated google.protobuf.FieldMask repeated_fieldmask = 313; | 192 repeated google.protobuf.FieldMask repeated_fieldmask = 313; |
| 246 repeated google.protobuf.Struct repeated_struct = 324; | 193 repeated google.protobuf.Struct repeated_struct = 324; |
| 247 repeated google.protobuf.Any repeated_any = 315; | 194 repeated google.protobuf.Any repeated_any = 315; |
| 248 repeated google.protobuf.Value repeated_value = 316; | 195 repeated google.protobuf.Value repeated_value = 316; |
| 249 | 196 |
| 250 // Test field-name-to-JSON-name convention. | 197 // Test field-name-to-JSON-name convention. |
| 198 // (protobuf says names can be any valid C/C++ identifier.) |
| 251 int32 fieldname1 = 401; | 199 int32 fieldname1 = 401; |
| 252 int32 field_name2 = 402; | 200 int32 field_name2 = 402; |
| 253 int32 _field_name3 = 403; | 201 int32 _field_name3 = 403; |
| 254 int32 field__name4_ = 404; | 202 int32 field__name4_ = 404; |
| 255 int32 field0name5 = 405; | 203 int32 field0name5 = 405; |
| 256 int32 field_0_name6 = 406; | 204 int32 field_0_name6 = 406; |
| 257 int32 fieldName7 = 407; | 205 int32 fieldName7 = 407; |
| 258 int32 FieldName8 = 408; | 206 int32 FieldName8 = 408; |
| 259 int32 field_Name9 = 409; | 207 int32 field_Name9 = 409; |
| 260 int32 Field_Name10 = 410; | 208 int32 Field_Name10 = 410; |
| 261 int32 FIELD_NAME11 = 411; | 209 int32 FIELD_NAME11 = 411; |
| 262 int32 FIELD_name12 = 412; | 210 int32 FIELD_name12 = 412; |
| 211 int32 __field_name13 = 413; |
| 212 int32 __Field_name14 = 414; |
| 213 int32 field__name15 = 415; |
| 214 int32 field__Name16 = 416; |
| 215 int32 field_name17__ = 417; |
| 216 int32 Field_name18__ = 418; |
| 263 } | 217 } |
| 264 | 218 |
| 265 message ForeignMessage { | 219 message ForeignMessage { |
| 266 int32 c = 1; | 220 int32 c = 1; |
| 267 } | 221 } |
| 268 | 222 |
| 269 enum ForeignEnum { | 223 enum ForeignEnum { |
| 270 FOREIGN_FOO = 0; | 224 FOREIGN_FOO = 0; |
| 271 FOREIGN_BAR = 1; | 225 FOREIGN_BAR = 1; |
| 272 FOREIGN_BAZ = 2; | 226 FOREIGN_BAZ = 2; |
| 273 } | 227 } |
| OLD | NEW |