Add editions-specific conformance tests
For now, these are limited to tests of text-form for delimited fields that locks down our problematic behavior in editions. Follow up changes will adjust the behavior to behave better under editions. PiperOrigin-RevId: 622211473pull/16427/head
parent
7ab65a08ac
commit
8ab39ed6f8
|
@ -18,10 +18,16 @@ add_custom_command(
|
|||
OUTPUT
|
||||
${protobuf_BINARY_DIR}/conformance/conformance.pb.h
|
||||
${protobuf_BINARY_DIR}/conformance/conformance.pb.cc
|
||||
DEPENDS ${protobuf_PROTOC_EXE} ${protobuf_SOURCE_DIR}/conformance/conformance.proto
|
||||
COMMAND ${protobuf_PROTOC_EXE} ${protobuf_SOURCE_DIR}/conformance/conformance.proto
|
||||
--proto_path=${protobuf_SOURCE_DIR}/conformance
|
||||
--cpp_out=${protobuf_BINARY_DIR}/conformance
|
||||
${protobuf_BINARY_DIR}/conformance/test_protos/test_messages_edition2023.pb.h
|
||||
${protobuf_BINARY_DIR}/conformance/test_protos/test_messages_edition2023.pb.cc
|
||||
DEPENDS ${protobuf_PROTOC_EXE}
|
||||
${protobuf_SOURCE_DIR}/conformance/conformance.proto
|
||||
${protobuf_SOURCE_DIR}/conformance/test_protos/test_messages_edition2023.proto
|
||||
COMMAND ${protobuf_PROTOC_EXE}
|
||||
${protobuf_SOURCE_DIR}/conformance/conformance.proto
|
||||
${protobuf_SOURCE_DIR}/conformance/test_protos/test_messages_edition2023.proto
|
||||
--proto_path=${protobuf_SOURCE_DIR}
|
||||
--cpp_out=${protobuf_BINARY_DIR}
|
||||
)
|
||||
|
||||
file(MAKE_DIRECTORY ${protobuf_BINARY_DIR}/src)
|
||||
|
@ -53,6 +59,8 @@ add_custom_command(
|
|||
add_library(libconformance_common STATIC
|
||||
${protobuf_BINARY_DIR}/conformance/conformance.pb.h
|
||||
${protobuf_BINARY_DIR}/conformance/conformance.pb.cc
|
||||
${protobuf_BINARY_DIR}/conformance/test_protos/test_messages_edition2023.pb.h
|
||||
${protobuf_BINARY_DIR}/conformance/test_protos/test_messages_edition2023.pb.cc
|
||||
${protobuf_BINARY_DIR}/src/google/protobuf/test_messages_proto2.pb.h
|
||||
${protobuf_BINARY_DIR}/src/google/protobuf/test_messages_proto2.pb.cc
|
||||
${protobuf_BINARY_DIR}/src/google/protobuf/test_messages_proto3.pb.h
|
||||
|
|
|
@ -29,7 +29,6 @@ exports_files([
|
|||
"failure_list_jruby.txt",
|
||||
"failure_list_jruby_ffi.txt",
|
||||
"text_format_failure_list_cpp.txt",
|
||||
"text_format_failure_list_csharp.txt",
|
||||
"text_format_failure_list_java.txt",
|
||||
"text_format_failure_list_java_lite.txt",
|
||||
"text_format_failure_list_php.txt",
|
||||
|
@ -191,6 +190,7 @@ cc_library(
|
|||
":conformance_test",
|
||||
":test_messages_proto2_proto_cc",
|
||||
":test_messages_proto3_proto_cc",
|
||||
"//conformance/test_protos:test_messages_edition2023_cc_proto",
|
||||
"//src/google/protobuf",
|
||||
"//src/google/protobuf/editions:test_messages_proto2_editions_cc_proto",
|
||||
"//src/google/protobuf/editions:test_messages_proto3_editions_cc_proto",
|
||||
|
@ -224,6 +224,7 @@ cc_binary(
|
|||
"//:protobuf",
|
||||
"//:test_messages_proto2_cc_proto",
|
||||
"//:test_messages_proto3_cc_proto",
|
||||
"//conformance/test_protos:test_messages_edition2023_cc_proto",
|
||||
"//src/google/protobuf",
|
||||
"//src/google/protobuf:port",
|
||||
"//src/google/protobuf:protobuf_lite",
|
||||
|
@ -254,6 +255,7 @@ java_binary(
|
|||
"//:protobuf_java_util",
|
||||
"//:test_messages_proto2_java_proto",
|
||||
"//:test_messages_proto3_java_proto",
|
||||
"//conformance/test_protos:test_messages_edition2023_java_proto",
|
||||
"//src/google/protobuf/editions:test_messages_proto2_editions_java_proto",
|
||||
"//src/google/protobuf/editions:test_messages_proto3_editions_java_proto",
|
||||
],
|
||||
|
@ -273,6 +275,7 @@ java_binary(
|
|||
"//:protobuf_javalite",
|
||||
"//:test_messages_proto2_java_proto_lite",
|
||||
"//:test_messages_proto3_java_proto_lite",
|
||||
"//conformance/test_protos:test_messages_edition2023_java_proto_lite",
|
||||
"//src/google/protobuf/editions:test_messages_proto2_editions_java_proto_lite",
|
||||
"//src/google/protobuf/editions:test_messages_proto3_editions_java_proto_lite",
|
||||
],
|
||||
|
@ -291,6 +294,7 @@ py_binary(
|
|||
deps = [
|
||||
":conformance_py_proto",
|
||||
"//:protobuf_python",
|
||||
"//conformance/test_protos:test_messages_edition2023_py_proto",
|
||||
"//python:_message", # Make upb visible if we need it.
|
||||
"//python:conformance_test_py_proto",
|
||||
],
|
||||
|
@ -342,6 +346,7 @@ inline_sh_binary(
|
|||
cmd = "dotnet $(rootpath //csharp/src/Google.Protobuf.Conformance:conformance_dll)",
|
||||
visibility = ["//csharp:__subpackages__"],
|
||||
deps = [
|
||||
"//conformance/test_protos:test_messages_edition2023_csharp_proto",
|
||||
"//csharp/src/Google.Protobuf.Conformance:conformance_runfiles",
|
||||
],
|
||||
)
|
||||
|
@ -356,6 +361,7 @@ objc_library(
|
|||
":conformance_objc_proto",
|
||||
"//:test_messages_proto2_objc_proto",
|
||||
"//:test_messages_proto3_objc_proto",
|
||||
"//conformance/test_protos:test_messages_edition2023_objc_proto",
|
||||
"//src/google/protobuf/editions:test_messages_proto2_editions_objc_proto",
|
||||
"//src/google/protobuf/editions:test_messages_proto3_editions_objc_proto",
|
||||
],
|
||||
|
@ -377,6 +383,7 @@ ruby_binary(
|
|||
visibility = ["//ruby:__subpackages__"],
|
||||
deps = [
|
||||
":conformance_ruby_proto",
|
||||
"//conformance/test_protos:test_messages_edition2023_ruby_proto",
|
||||
"//ruby:conformance_test_ruby_proto",
|
||||
"//ruby:protobuf",
|
||||
],
|
||||
|
|
|
@ -15,6 +15,8 @@ import com.google.protobuf.TextFormat;
|
|||
import com.google.protobuf.conformance.Conformance;
|
||||
import com.google.protobuf.util.JsonFormat;
|
||||
import com.google.protobuf.util.JsonFormat.TypeRegistry;
|
||||
import com.google.protobuf_test_messages.edition2023.TestAllTypesEdition2023;
|
||||
import com.google.protobuf_test_messages.edition2023.TestMessagesEdition2023;
|
||||
import com.google.protobuf_test_messages.editions.proto2.TestMessagesProto2Editions;
|
||||
import com.google.protobuf_test_messages.editions.proto3.TestMessagesProto3Editions;
|
||||
import com.google.protobuf_test_messages.proto2.TestMessagesProto2;
|
||||
|
@ -213,6 +215,8 @@ class ConformanceJava {
|
|||
return TestAllTypesProto3.class;
|
||||
case "protobuf_test_messages.proto2.TestAllTypesProto2":
|
||||
return TestAllTypesProto2.class;
|
||||
case "protobuf_test_messages.editions.TestAllTypesEdition2023":
|
||||
return TestAllTypesEdition2023.class;
|
||||
case "protobuf_test_messages.editions.proto3.TestAllTypesProto3":
|
||||
return TestMessagesProto3Editions.TestAllTypesProto3.class;
|
||||
case "protobuf_test_messages.editions.proto2.TestAllTypesProto2":
|
||||
|
@ -229,6 +233,8 @@ class ConformanceJava {
|
|||
return TestMessagesProto3.class;
|
||||
case "protobuf_test_messages.proto2.TestAllTypesProto2":
|
||||
return TestMessagesProto2.class;
|
||||
case "protobuf_test_messages.editions.TestAllTypesEdition2023":
|
||||
return TestMessagesEdition2023.class;
|
||||
case "protobuf_test_messages.editions.proto3.TestAllTypesProto3":
|
||||
return TestMessagesProto3Editions.class;
|
||||
case "protobuf_test_messages.editions.proto2.TestAllTypesProto2":
|
||||
|
|
|
@ -13,11 +13,13 @@ import com.google.protobuf.InvalidProtocolBufferException;
|
|||
import com.google.protobuf.MessageLite;
|
||||
import com.google.protobuf.Parser;
|
||||
import com.google.protobuf.conformance.Conformance;
|
||||
import com.google.protobuf_test_messages.edition2023.TestAllTypesEdition2023;
|
||||
import com.google.protobuf_test_messages.edition2023.TestMessagesEdition2023;
|
||||
import com.google.protobuf_test_messages.editions.proto2.TestMessagesProto2Editions;
|
||||
import com.google.protobuf_test_messages.editions.proto3.TestMessagesProto3Editions;
|
||||
import com.google.protobuf_test_messages.proto2.TestMessagesProto2;
|
||||
import com.google.protobuf_test_messages.proto2.TestMessagesProto2.TestAllTypesProto2;
|
||||
import com.google.protobuf_test_messages.proto3.TestMessagesProto3;
|
||||
import com.google.protobuf_test_messages.editions.proto2.TestMessagesProto2Editions;
|
||||
import com.google.protobuf_test_messages.editions.proto3.TestMessagesProto3Editions;
|
||||
import com.google.protobuf_test_messages.proto3.TestMessagesProto3.TestAllTypesProto3;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
|
@ -212,6 +214,8 @@ class ConformanceJavaLite {
|
|||
return TestAllTypesProto3.class;
|
||||
case "protobuf_test_messages.proto2.TestAllTypesProto2":
|
||||
return TestAllTypesProto2.class;
|
||||
case "protobuf_test_messages.edition2023.TestAllTypesEdition2023":
|
||||
return TestAllTypesEdition2023.class;
|
||||
case "protobuf_test_messages.editions.proto3.TestAllTypesProto3":
|
||||
return TestMessagesProto3Editions.TestAllTypesProto3.class;
|
||||
case "protobuf_test_messages.editions.proto2.TestAllTypesProto2":
|
||||
|
@ -228,6 +232,8 @@ class ConformanceJavaLite {
|
|||
return TestMessagesProto3.class;
|
||||
case "protobuf_test_messages.proto2.TestAllTypesProto2":
|
||||
return TestMessagesProto2.class;
|
||||
case "protobuf_test_messages.edition2023.TestAllTypesEdition2023":
|
||||
return TestMessagesEdition2023.class;
|
||||
case "protobuf_test_messages.editions.proto3.TestAllTypesProto3":
|
||||
return TestMessagesProto3Editions.class;
|
||||
case "protobuf_test_messages.editions.proto2.TestAllTypesProto2":
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "absl/strings/str_cat.h"
|
||||
#include "conformance/conformance.pb.h"
|
||||
#include "conformance/conformance.pb.h"
|
||||
#include "conformance/test_protos/test_messages_edition2023.pb.h"
|
||||
#include "google/protobuf/editions/golden/test_messages_proto2_editions.pb.h"
|
||||
#include "google/protobuf/editions/golden/test_messages_proto3_editions.pb.h"
|
||||
#include "google/protobuf/endian.h"
|
||||
|
@ -47,6 +48,7 @@ using ::google::protobuf::util::JsonParseOptions;
|
|||
using ::google::protobuf::util::JsonToBinaryString;
|
||||
using ::google::protobuf::util::NewTypeResolverForDescriptorPool;
|
||||
using ::google::protobuf::util::TypeResolver;
|
||||
using ::protobuf_test_messages::editions::TestAllTypesEdition2023;
|
||||
using ::protobuf_test_messages::proto2::TestAllTypesProto2;
|
||||
using ::protobuf_test_messages::proto3::TestAllTypesProto3;
|
||||
using TestAllTypesProto2Editions =
|
||||
|
@ -84,6 +86,7 @@ class Harness {
|
|||
Harness() {
|
||||
google::protobuf::LinkMessageReflection<TestAllTypesProto2>();
|
||||
google::protobuf::LinkMessageReflection<TestAllTypesProto3>();
|
||||
google::protobuf::LinkMessageReflection<TestAllTypesEdition2023>();
|
||||
google::protobuf::LinkMessageReflection<TestAllTypesProto2Editions>();
|
||||
google::protobuf::LinkMessageReflection<TestAllTypesProto3Editions>();
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#import "google/protobuf/TestMessagesProto3.pbobjc.h"
|
||||
#import "google/protobuf/editions/golden/TestMessagesProto2Editions.pbobjc.h"
|
||||
#import "google/protobuf/editions/golden/TestMessagesProto3Editions.pbobjc.h"
|
||||
#import "test_protos/TestMessagesEdition2023.pbobjc.h"
|
||||
|
||||
static void Die(NSString *format, ...) __dead2;
|
||||
|
||||
|
@ -54,6 +55,8 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) {
|
|||
NSDictionary *mappings = @{
|
||||
@"protobuf_test_messages.proto2.TestAllTypesProto2" : [Proto2TestAllTypesProto2 class],
|
||||
@"protobuf_test_messages.proto3.TestAllTypesProto3" : [Proto3TestAllTypesProto3 class],
|
||||
@"protobuf_test_messages.editions.TestAllTypesEdition2023" :
|
||||
[EditionsTestAllTypesEdition2023 class],
|
||||
@"protobuf_test_messages.editions.proto2.TestAllTypesProto2" :
|
||||
[EditionsProto2TestAllTypesProto2 class],
|
||||
@"protobuf_test_messages.editions.proto3.TestAllTypesProto3" :
|
||||
|
|
|
@ -19,6 +19,7 @@ from google.protobuf import text_format
|
|||
from google.protobuf import test_messages_proto2_pb2
|
||||
from google.protobuf import test_messages_proto3_pb2
|
||||
from conformance import conformance_pb2
|
||||
from conformance.test_protos import test_messages_edition2023_pb2
|
||||
from google.protobuf.editions.golden import test_messages_proto2_editions_pb2
|
||||
from google.protobuf.editions.golden import test_messages_proto3_editions_pb2
|
||||
|
||||
|
@ -35,6 +36,8 @@ def _create_test_message(type):
|
|||
return test_messages_proto2_pb2.TestAllTypesProto2()
|
||||
if type == "protobuf_test_messages.proto3.TestAllTypesProto3":
|
||||
return test_messages_proto3_pb2.TestAllTypesProto3()
|
||||
if type == "protobuf_test_messages.editions.TestAllTypesEdition2023":
|
||||
return test_messages_edition2023_pb2.TestAllTypesEdition2023()
|
||||
if type == "protobuf_test_messages.editions.proto2.TestAllTypesProto2":
|
||||
return test_messages_proto2_editions_pb2.TestAllTypesProto2()
|
||||
if type == "protobuf_test_messages.editions.proto3.TestAllTypesProto3":
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
# https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
require 'conformance/conformance_pb'
|
||||
require 'conformance/test_protos/test_messages_edition2023_pb'
|
||||
require 'google/protobuf'
|
||||
require 'google/protobuf/test_messages_proto3_pb'
|
||||
require 'google/protobuf/test_messages_proto2_pb'
|
||||
|
@ -24,6 +25,7 @@ def do_test(request)
|
|||
|
||||
unless descriptor
|
||||
response.runtime_error = "Unknown message type: " + request.message_type
|
||||
return response
|
||||
end
|
||||
|
||||
if request.test_category == :TEXT_FORMAT_TEST
|
||||
|
|
|
@ -15,6 +15,7 @@ use protobuf_upb as kernel;
|
|||
use kernel::Optional::{Set, Unset};
|
||||
|
||||
use std::io::{self, ErrorKind, Read, Write};
|
||||
use test_messages_edition2023_proto::TestAllTypesEdition2023;
|
||||
use test_messages_proto2::TestAllTypesProto2;
|
||||
use test_messages_proto2_editions_proto::TestAllTypesProto2 as EditionsTestAllTypesProto2;
|
||||
use test_messages_proto3::TestAllTypesProto3;
|
||||
|
@ -89,6 +90,14 @@ fn do_test(req: &ConformanceRequest) -> ConformanceResponse {
|
|||
return resp;
|
||||
}
|
||||
}
|
||||
b"protobuf_test_messages.editions.TestAllTypesEdition2023" => {
|
||||
if let Ok(msg) = TestAllTypesEdition2023::parse(bytes) {
|
||||
msg.serialize()
|
||||
} else {
|
||||
resp.set_parse_error("failed to parse bytes");
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
b"protobuf_test_messages.editions.proto2.TestAllTypesProto2" => {
|
||||
if let Ok(msg) = EditionsTestAllTypesProto2::parse(bytes) {
|
||||
msg.serialize()
|
||||
|
|
|
@ -15,3 +15,21 @@ Recommended.Proto3.ValueRejectInfNumberValue.JsonOutput
|
|||
Recommended.Proto3.ValueRejectNanNumberValue.JsonOutput
|
||||
Required.Proto2.ProtobufInput.UnknownOrdering.ProtobufOutput
|
||||
Required.Proto3.ProtobufInput.UnknownOrdering.ProtobufOutput
|
||||
|
||||
Recommended.Editions_Proto2.JsonInput.FieldNameExtension.Validator
|
||||
Recommended.Editions_Proto2.JsonInput.BytesFieldBase64Url.JsonOutput
|
||||
Recommended.Editions_Proto2.JsonInput.BytesFieldBase64Url.ProtobufOutput
|
||||
Recommended.Editions_Proto3.JsonInput.BytesFieldBase64Url.JsonOutput
|
||||
Recommended.Editions_Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
|
||||
Required.Editions_Proto2.JsonInput.OneofFieldNullFirst.JsonOutput
|
||||
Required.Editions_Proto2.JsonInput.OneofFieldNullFirst.ProtobufOutput
|
||||
Required.Editions_Proto2.JsonInput.OneofFieldNullSecond.JsonOutput
|
||||
Required.Editions_Proto2.JsonInput.OneofFieldNullSecond.ProtobufOutput
|
||||
Required.Editions_Proto3.JsonInput.OneofFieldNullFirst.JsonOutput
|
||||
Required.Editions_Proto3.JsonInput.OneofFieldNullFirst.ProtobufOutput
|
||||
Required.Editions_Proto3.JsonInput.OneofFieldNullSecond.JsonOutput
|
||||
Required.Editions_Proto3.JsonInput.OneofFieldNullSecond.ProtobufOutput
|
||||
Recommended.Editions_Proto3.ValueRejectInfNumberValue.JsonOutput
|
||||
Recommended.Editions_Proto3.ValueRejectNanNumberValue.JsonOutput
|
||||
Required.Editions_Proto2.ProtobufInput.UnknownOrdering.ProtobufOutput
|
||||
Required.Editions_Proto3.ProtobufInput.UnknownOrdering.ProtobufOutput
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
load("@rules_cc//cc:defs.bzl", "cc_proto_library", "objc_library")
|
||||
load("//:protobuf.bzl", "internal_csharp_proto_library", "internal_objc_proto_library", "internal_py_proto_library")
|
||||
load("//ruby:defs.bzl", "internal_ruby_proto_library")
|
||||
|
||||
package(
|
||||
default_testonly = True,
|
||||
default_visibility = ["//conformance:__pkg__"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "test_messages_edition2023_proto",
|
||||
srcs = ["test_messages_edition2023.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
cc_proto_library(
|
||||
name = "test_messages_edition2023_cc_proto",
|
||||
deps = [":test_messages_edition2023_proto"],
|
||||
)
|
||||
|
||||
internal_csharp_proto_library(
|
||||
name = "test_messages_edition2023_csharp_proto",
|
||||
srcs = ["test_messages_edition2023.proto"],
|
||||
)
|
||||
|
||||
java_proto_library(
|
||||
name = "test_messages_edition2023_java_proto",
|
||||
deps = [":test_messages_edition2023_proto"],
|
||||
)
|
||||
|
||||
java_lite_proto_library(
|
||||
name = "test_messages_edition2023_java_proto_lite",
|
||||
deps = [":test_messages_edition2023_proto"],
|
||||
)
|
||||
|
||||
internal_py_proto_library(
|
||||
name = "test_messages_edition2023_py_proto",
|
||||
srcs = ["test_messages_edition2023.proto"],
|
||||
srcs_version = "PY2AND3",
|
||||
)
|
||||
|
||||
internal_objc_proto_library(
|
||||
name = "test_messages_edition2023_objc_proto",
|
||||
srcs = ["test_messages_edition2023.proto"],
|
||||
)
|
||||
|
||||
internal_ruby_proto_library(
|
||||
name = "test_messages_edition2023_ruby_proto",
|
||||
srcs = ["test_messages_edition2023.proto"],
|
||||
)
|
|
@ -0,0 +1,198 @@
|
|||
edition = "2023";
|
||||
|
||||
package protobuf_test_messages.editions;
|
||||
|
||||
option java_package = "com.google.protobuf_test_messages.edition2023";
|
||||
option java_multiple_files = true;
|
||||
option objc_class_prefix = "Editions";
|
||||
|
||||
message TestAllTypesEdition2023 {
|
||||
message NestedMessage {
|
||||
int32 a = 1;
|
||||
TestAllTypesEdition2023 corecursive = 2;
|
||||
}
|
||||
|
||||
enum NestedEnum {
|
||||
FOO = 0;
|
||||
BAR = 1;
|
||||
BAZ = 2;
|
||||
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;
|
||||
|
||||
NestedMessage optional_nested_message = 18;
|
||||
ForeignMessageEdition2023 optional_foreign_message = 19;
|
||||
|
||||
NestedEnum optional_nested_enum = 21;
|
||||
ForeignEnumEdition2023 optional_foreign_enum = 22;
|
||||
|
||||
string optional_string_piece = 24 [ctype = STRING_PIECE];
|
||||
string optional_cord = 25 [ctype = CORD];
|
||||
|
||||
TestAllTypesEdition2023 recursive_message = 27;
|
||||
|
||||
// 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;
|
||||
|
||||
repeated NestedMessage repeated_nested_message = 48;
|
||||
repeated ForeignMessageEdition2023 repeated_foreign_message = 49;
|
||||
|
||||
repeated NestedEnum repeated_nested_enum = 51;
|
||||
repeated ForeignEnumEdition2023 repeated_foreign_enum = 52;
|
||||
|
||||
repeated string repeated_string_piece = 54 [ctype = STRING_PIECE];
|
||||
repeated string repeated_cord = 55 [ctype = CORD];
|
||||
|
||||
// Packed
|
||||
repeated int32 packed_int32 = 75 [features.repeated_field_encoding = PACKED];
|
||||
repeated int64 packed_int64 = 76 [features.repeated_field_encoding = PACKED];
|
||||
repeated uint32 packed_uint32 = 77
|
||||
[features.repeated_field_encoding = PACKED];
|
||||
repeated uint64 packed_uint64 = 78
|
||||
[features.repeated_field_encoding = PACKED];
|
||||
repeated sint32 packed_sint32 = 79
|
||||
[features.repeated_field_encoding = PACKED];
|
||||
repeated sint64 packed_sint64 = 80
|
||||
[features.repeated_field_encoding = PACKED];
|
||||
repeated fixed32 packed_fixed32 = 81
|
||||
[features.repeated_field_encoding = PACKED];
|
||||
repeated fixed64 packed_fixed64 = 82
|
||||
[features.repeated_field_encoding = PACKED];
|
||||
repeated sfixed32 packed_sfixed32 = 83
|
||||
[features.repeated_field_encoding = PACKED];
|
||||
repeated sfixed64 packed_sfixed64 = 84
|
||||
[features.repeated_field_encoding = PACKED];
|
||||
repeated float packed_float = 85 [features.repeated_field_encoding = PACKED];
|
||||
repeated double packed_double = 86
|
||||
[features.repeated_field_encoding = PACKED];
|
||||
repeated bool packed_bool = 87 [features.repeated_field_encoding = PACKED];
|
||||
repeated NestedEnum packed_nested_enum = 88
|
||||
[features.repeated_field_encoding = PACKED];
|
||||
|
||||
// Unpacked
|
||||
repeated int32 unpacked_int32 = 89
|
||||
[features.repeated_field_encoding = EXPANDED];
|
||||
repeated int64 unpacked_int64 = 90
|
||||
[features.repeated_field_encoding = EXPANDED];
|
||||
repeated uint32 unpacked_uint32 = 91
|
||||
[features.repeated_field_encoding = EXPANDED];
|
||||
repeated uint64 unpacked_uint64 = 92
|
||||
[features.repeated_field_encoding = EXPANDED];
|
||||
repeated sint32 unpacked_sint32 = 93
|
||||
[features.repeated_field_encoding = EXPANDED];
|
||||
repeated sint64 unpacked_sint64 = 94
|
||||
[features.repeated_field_encoding = EXPANDED];
|
||||
repeated fixed32 unpacked_fixed32 = 95
|
||||
[features.repeated_field_encoding = EXPANDED];
|
||||
repeated fixed64 unpacked_fixed64 = 96
|
||||
[features.repeated_field_encoding = EXPANDED];
|
||||
repeated sfixed32 unpacked_sfixed32 = 97
|
||||
[features.repeated_field_encoding = EXPANDED];
|
||||
repeated sfixed64 unpacked_sfixed64 = 98
|
||||
[features.repeated_field_encoding = EXPANDED];
|
||||
repeated float unpacked_float = 99
|
||||
[features.repeated_field_encoding = EXPANDED];
|
||||
repeated double unpacked_double = 100
|
||||
[features.repeated_field_encoding = EXPANDED];
|
||||
repeated bool unpacked_bool = 101
|
||||
[features.repeated_field_encoding = EXPANDED];
|
||||
repeated NestedEnum unpacked_nested_enum = 102
|
||||
[features.repeated_field_encoding = EXPANDED];
|
||||
|
||||
// Map
|
||||
map<int32, int32> map_int32_int32 = 56;
|
||||
map<int64, int64> map_int64_int64 = 57;
|
||||
map<uint32, uint32> map_uint32_uint32 = 58;
|
||||
map<uint64, uint64> map_uint64_uint64 = 59;
|
||||
map<sint32, sint32> map_sint32_sint32 = 60;
|
||||
map<sint64, sint64> map_sint64_sint64 = 61;
|
||||
map<fixed32, fixed32> map_fixed32_fixed32 = 62;
|
||||
map<fixed64, fixed64> map_fixed64_fixed64 = 63;
|
||||
map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 64;
|
||||
map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 65;
|
||||
map<int32, float> map_int32_float = 66;
|
||||
map<int32, double> map_int32_double = 67;
|
||||
map<bool, bool> map_bool_bool = 68;
|
||||
map<string, string> map_string_string = 69;
|
||||
map<string, bytes> map_string_bytes = 70;
|
||||
map<string, NestedMessage> map_string_nested_message = 71;
|
||||
map<string, ForeignMessageEdition2023> map_string_foreign_message = 72;
|
||||
map<string, NestedEnum> map_string_nested_enum = 73;
|
||||
map<string, ForeignEnumEdition2023> map_string_foreign_enum = 74;
|
||||
|
||||
oneof oneof_field {
|
||||
uint32 oneof_uint32 = 111;
|
||||
NestedMessage oneof_nested_message = 112;
|
||||
string oneof_string = 113;
|
||||
bytes oneof_bytes = 114;
|
||||
bool oneof_bool = 115;
|
||||
uint64 oneof_uint64 = 116;
|
||||
float oneof_float = 117;
|
||||
double oneof_double = 118;
|
||||
NestedEnum oneof_enum = 119;
|
||||
}
|
||||
|
||||
// extensions
|
||||
extensions 120 to 200;
|
||||
|
||||
// groups
|
||||
message GroupLikeType {
|
||||
int32 group_int32 = 202;
|
||||
uint32 group_uint32 = 203;
|
||||
}
|
||||
GroupLikeType groupliketype = 201 [features.message_encoding = DELIMITED];
|
||||
GroupLikeType delimited_field = 202 [features.message_encoding = DELIMITED];
|
||||
}
|
||||
|
||||
message ForeignMessageEdition2023 {
|
||||
int32 c = 1;
|
||||
}
|
||||
|
||||
enum ForeignEnumEdition2023 {
|
||||
FOREIGN_FOO = 0;
|
||||
FOREIGN_BAR = 1;
|
||||
FOREIGN_BAZ = 2;
|
||||
}
|
||||
|
||||
extend TestAllTypesEdition2023 {
|
||||
int32 extension_int32 = 120;
|
||||
}
|
||||
|
||||
message GroupLikeType {
|
||||
int32 c = 1;
|
||||
}
|
||||
|
||||
extend TestAllTypesEdition2023 {
|
||||
GroupLikeType groupliketype = 121 [features.message_encoding = DELIMITED];
|
||||
GroupLikeType delimited_ext = 122 [features.message_encoding = DELIMITED];
|
||||
}
|
|
@ -16,6 +16,7 @@
|
|||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "conformance_test.h"
|
||||
#include "conformance/test_protos/test_messages_edition2023.pb.h"
|
||||
#include "google/protobuf/editions/golden/test_messages_proto2_editions.pb.h"
|
||||
#include "google/protobuf/editions/golden/test_messages_proto3_editions.pb.h"
|
||||
#include "google/protobuf/test_messages_proto2.pb.h"
|
||||
|
@ -25,6 +26,7 @@
|
|||
using conformance::ConformanceRequest;
|
||||
using conformance::ConformanceResponse;
|
||||
using conformance::WireFormat;
|
||||
using protobuf_test_messages::editions::TestAllTypesEdition2023;
|
||||
using protobuf_test_messages::proto2::TestAllTypesProto2;
|
||||
using protobuf_test_messages::proto2::UnknownToTestAllTypes;
|
||||
using protobuf_test_messages::proto3::TestAllTypesProto3;
|
||||
|
@ -123,6 +125,7 @@ void TextFormatConformanceTestSuite::RunSuiteImpl() {
|
|||
if (maximum_edition_ >= Edition::EDITION_2023) {
|
||||
TextFormatConformanceTestSuiteImpl<TestAllTypesProto2Editions>(this);
|
||||
TextFormatConformanceTestSuiteImpl<TestAllTypesProto3Editions>(this);
|
||||
TextFormatConformanceTestSuiteImpl<TestAllTypesEdition2023>(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,11 +135,18 @@ TextFormatConformanceTestSuiteImpl<MessageType>::
|
|||
: suite_(*ABSL_DIE_IF_NULL(suite)) {
|
||||
// Flag control performance tests to keep them internal and opt-in only
|
||||
if (suite_.performance_) {
|
||||
if (MessageType::GetDescriptor()->name() == "TestAllTypesEdition2023") {
|
||||
// There are no editions-sensitive performance tests.
|
||||
return;
|
||||
}
|
||||
RunTextFormatPerformanceTests();
|
||||
} else {
|
||||
if (MessageType::GetDescriptor()->name() == "TestAllTypesProto2") {
|
||||
RunGroupTests();
|
||||
}
|
||||
if (MessageType::GetDescriptor()->name() == "TestAllTypesEdition2023") {
|
||||
RunDelimitedTests();
|
||||
}
|
||||
if (MessageType::GetDescriptor()->name() == "TestAllTypesProto3") {
|
||||
RunAnyTests();
|
||||
// TODO Run these over proto2 also.
|
||||
|
@ -236,6 +246,34 @@ void TextFormatConformanceTestSuiteImpl<
|
|||
suite_.RunValidBinaryInputTest(setting2, serialized_input);
|
||||
}
|
||||
|
||||
template <typename MessageType>
|
||||
void TextFormatConformanceTestSuiteImpl<MessageType>::RunDelimitedTests() {
|
||||
RunValidTextFormatTest("GroupFieldNoColon", REQUIRED,
|
||||
"GroupLikeType { group_int32: 1 }");
|
||||
RunValidTextFormatTest("GroupFieldWithColon", REQUIRED,
|
||||
"GroupLikeType: { group_int32: 1 }");
|
||||
RunValidTextFormatTest("GroupFieldEmpty", REQUIRED, "GroupLikeType {}");
|
||||
RunValidTextFormatTest(
|
||||
"GroupFieldExtension", REQUIRED,
|
||||
"[protobuf_test_messages.editions.groupliketype] { c: 1 }");
|
||||
RunValidTextFormatTest(
|
||||
"DelimitedFieldExtension", REQUIRED,
|
||||
"[protobuf_test_messages.editions.delimited_ext] { c: 1 }");
|
||||
|
||||
// Test that lower-cased group name (i.e. implicit field name) is not accepted
|
||||
// for now.
|
||||
ExpectParseFailure("DelimitedFieldLowercased", REQUIRED,
|
||||
"groupliketype { group_int32: 1 }");
|
||||
ExpectParseFailure("DelimitedFieldLowercasedDifferent", REQUIRED,
|
||||
"delimited_field { group_int32: 1 }");
|
||||
|
||||
// Extensions always used the field name, and should never accept the message
|
||||
// name.
|
||||
ExpectParseFailure(
|
||||
"DelimitedFieldExtensionMessageName", REQUIRED,
|
||||
"[protobuf_test_messages.editions.GroupLikeType] { group_int32: 1 }");
|
||||
}
|
||||
|
||||
template <typename MessageType>
|
||||
void TextFormatConformanceTestSuiteImpl<MessageType>::RunGroupTests() {
|
||||
RunValidTextFormatTest("GroupFieldNoColon", REQUIRED,
|
||||
|
|
|
@ -49,6 +49,7 @@ class TextFormatConformanceTestSuiteImpl {
|
|||
|
||||
void RunAllTests();
|
||||
|
||||
void RunDelimitedTests();
|
||||
void RunGroupTests();
|
||||
void RunAnyTests();
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
Recommended.Proto3.ProtobufInput.GroupUnknownFields_Drop.TextFormatOutput
|
||||
Recommended.Proto3.ProtobufInput.GroupUnknownFields_Print.TextFormatOutput
|
||||
Recommended.Proto3.ProtobufInput.MessageUnknownFields_Drop.TextFormatOutput
|
||||
Recommended.Proto3.ProtobufInput.MessageUnknownFields_Print.TextFormatOutput
|
||||
Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Drop.TextFormatOutput
|
||||
Recommended.Proto3.ProtobufInput.RepeatedUnknownFields_Print.TextFormatOutput
|
||||
Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Drop.TextFormatOutput
|
||||
Recommended.Proto3.ProtobufInput.ScalarUnknownFields_Print.TextFormatOutput
|
|
@ -13,8 +13,8 @@ load("//conformance:defs.bzl", "conformance_test")
|
|||
conformance_test(
|
||||
name = "conformance_test",
|
||||
failure_list = "//conformance:failure_list_csharp.txt",
|
||||
maximum_edition = "2023",
|
||||
testee = "//conformance:conformance_csharp",
|
||||
text_format_failure_list = "//conformance:text_format_failure_list_csharp.txt",
|
||||
)
|
||||
|
||||
################################################################################
|
||||
|
|
|
@ -52,11 +52,13 @@ $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \
|
|||
# of protoc.
|
||||
$PROTOC -Isrc -I. \
|
||||
--experimental_allow_proto3_optional \
|
||||
--experimental_editions \
|
||||
--csharp_out=csharp/src/Google.Protobuf.Test.TestProtos \
|
||||
--csharp_opt=file_extension=.pb.cs \
|
||||
--descriptor_set_out=csharp/src/Google.Protobuf.Test/testprotos.pb \
|
||||
--include_source_info \
|
||||
--include_imports \
|
||||
conformance/test_protos/test_messages_edition2023.proto \
|
||||
csharp/protos/map_unittest_proto3.proto \
|
||||
csharp/protos/unittest_issues.proto \
|
||||
csharp/protos/unittest_custom_options_proto3.proto \
|
||||
|
@ -70,6 +72,8 @@ $PROTOC -Isrc -I. \
|
|||
csharp/protos/unittest_issue6936_b.proto \
|
||||
csharp/protos/unittest_issue6936_c.proto \
|
||||
csharp/protos/unittest_selfreferential_options.proto \
|
||||
src/google/protobuf/editions/golden/test_messages_proto3_editions.proto \
|
||||
src/google/protobuf/editions/golden/test_messages_proto2_editions.proto \
|
||||
src/google/protobuf/unittest_well_known_types.proto \
|
||||
src/google/protobuf/test_messages_proto3.proto \
|
||||
src/google/protobuf/test_messages_proto2.proto \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#region Copyright notice and license
|
||||
#region Copyright notice and license
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 Google Inc. All rights reserved.
|
||||
//
|
||||
|
@ -27,7 +27,10 @@ namespace Google.Protobuf.Conformance
|
|||
var output = new BinaryWriter(Console.OpenStandardOutput());
|
||||
var typeRegistry = TypeRegistry.FromMessages(
|
||||
ProtobufTestMessages.Proto3.TestAllTypesProto3.Descriptor,
|
||||
ProtobufTestMessages.Proto2.TestAllTypesProto2.Descriptor);
|
||||
ProtobufTestMessages.Proto2.TestAllTypesProto2.Descriptor,
|
||||
ProtobufTestMessages.Editions.TestAllTypesEdition2023.Descriptor,
|
||||
ProtobufTestMessages.Editions.Proto3.TestAllTypesProto3.Descriptor,
|
||||
ProtobufTestMessages.Editions.Proto2.TestAllTypesProto2.Descriptor);
|
||||
|
||||
int count = 0;
|
||||
while (RunTest(input, output, typeRegistry))
|
||||
|
@ -66,6 +69,20 @@ namespace Google.Protobuf.Conformance
|
|||
ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.MessageSetCorrectExtension1.Extensions.MessageSetExtension,
|
||||
ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.MessageSetCorrectExtension2.Extensions.MessageSetExtension
|
||||
};
|
||||
ExtensionRegistry editionsProto2ExtensionRegistry = new ExtensionRegistry
|
||||
{
|
||||
ProtobufTestMessages.Editions.Proto2.TestMessagesProto2EditionsExtensions
|
||||
.ExtensionInt32,
|
||||
ProtobufTestMessages.Editions.Proto2.TestAllTypesProto2.Types
|
||||
.MessageSetCorrectExtension1.Extensions.MessageSetExtension,
|
||||
ProtobufTestMessages.Editions.Proto2.TestAllTypesProto2.Types
|
||||
.MessageSetCorrectExtension2.Extensions.MessageSetExtension
|
||||
};
|
||||
ExtensionRegistry edition2023ExtensionRegistry = new ExtensionRegistry
|
||||
{
|
||||
ProtobufTestMessages.Editions.TestMessagesEdition2023Extensions.ExtensionInt32,
|
||||
ProtobufTestMessages.Editions.TestMessagesEdition2023Extensions.DelimitedExt
|
||||
};
|
||||
IMessage message;
|
||||
try
|
||||
{
|
||||
|
@ -76,23 +93,53 @@ namespace Google.Protobuf.Conformance
|
|||
JsonParser parser = new JsonParser(new JsonParser.Settings(20, typeRegistry).WithIgnoreUnknownFields(ignoreUnknownFields));
|
||||
message = request.MessageType switch
|
||||
{
|
||||
"protobuf_test_messages.proto3.TestAllTypesProto3" => parser.Parse<ProtobufTestMessages.Proto3.TestAllTypesProto3>(request.JsonPayload),
|
||||
"protobuf_test_messages.proto2.TestAllTypesProto2" => parser.Parse<ProtobufTestMessages.Proto2.TestAllTypesProto2>(request.JsonPayload),
|
||||
_ => throw new Exception($" Protobuf request doesn't have specific payload type ({request.MessageType})"),
|
||||
"protobuf_test_messages.proto2.TestAllTypesProto2" =>
|
||||
parser.Parse<ProtobufTestMessages.Proto2.TestAllTypesProto2>(
|
||||
request.JsonPayload),
|
||||
"protobuf_test_messages.proto3.TestAllTypesProto3" =>
|
||||
parser.Parse<ProtobufTestMessages.Proto3.TestAllTypesProto3>(
|
||||
request.JsonPayload),
|
||||
"protobuf_test_messages.editions.TestAllTypesEdition2023" =>
|
||||
parser.Parse<ProtobufTestMessages.Editions.TestAllTypesEdition2023>(
|
||||
request.JsonPayload),
|
||||
"protobuf_test_messages.editions.proto2.TestAllTypesProto2" =>
|
||||
parser.Parse<ProtobufTestMessages.Editions.Proto2.TestAllTypesProto2>(
|
||||
request.JsonPayload),
|
||||
"protobuf_test_messages.editions.proto3.TestAllTypesProto3" =>
|
||||
parser.Parse<ProtobufTestMessages.Editions.Proto3.TestAllTypesProto3>(
|
||||
request.JsonPayload),
|
||||
_ => throw new Exception(
|
||||
$" Protobuf request doesn't have specific payload type ({request.MessageType})"),
|
||||
};
|
||||
break;
|
||||
case ConformanceRequest.PayloadOneofCase.ProtobufPayload:
|
||||
message = request.MessageType switch
|
||||
{
|
||||
"protobuf_test_messages.proto3.TestAllTypesProto3" => ProtobufTestMessages.Proto3.TestAllTypesProto3.Parser.ParseFrom(request.ProtobufPayload),
|
||||
"protobuf_test_messages.proto2.TestAllTypesProto2" => ProtobufTestMessages.Proto2.TestAllTypesProto2.Parser
|
||||
.WithExtensionRegistry(proto2ExtensionRegistry)
|
||||
.ParseFrom(request.ProtobufPayload),
|
||||
_ => throw new Exception($" Protobuf request doesn't have specific payload type ({request.MessageType})"),
|
||||
};
|
||||
break;
|
||||
case ConformanceRequest.PayloadOneofCase.TextPayload:
|
||||
return new ConformanceResponse { Skipped = "CSharp doesn't support text format" };
|
||||
message = request.MessageType switch
|
||||
{
|
||||
"protobuf_test_messages.proto2.TestAllTypesProto2" =>
|
||||
ProtobufTestMessages.Proto2.TestAllTypesProto2.Parser
|
||||
.WithExtensionRegistry(proto2ExtensionRegistry)
|
||||
.ParseFrom(request.ProtobufPayload),
|
||||
"protobuf_test_messages.proto3.TestAllTypesProto3" =>
|
||||
ProtobufTestMessages.Proto3.TestAllTypesProto3.Parser.ParseFrom(
|
||||
request.ProtobufPayload),
|
||||
"protobuf_test_messages.editions.TestAllTypesEdition2023" =>
|
||||
ProtobufTestMessages.Editions.TestAllTypesEdition2023.Parser
|
||||
.WithExtensionRegistry(edition2023ExtensionRegistry)
|
||||
.ParseFrom(request.ProtobufPayload),
|
||||
"protobuf_test_messages.editions.proto2.TestAllTypesProto2" =>
|
||||
ProtobufTestMessages.Editions.Proto2.TestAllTypesProto2.Parser
|
||||
.WithExtensionRegistry(editionsProto2ExtensionRegistry)
|
||||
.ParseFrom(request.ProtobufPayload),
|
||||
"protobuf_test_messages.editions.proto3.TestAllTypesProto3" =>
|
||||
ProtobufTestMessages.Editions.Proto3.TestAllTypesProto3.Parser
|
||||
.ParseFrom(request.ProtobufPayload),
|
||||
_ => throw new Exception(
|
||||
$" Protobuf request doesn't have specific payload type ({request.MessageType})"),
|
||||
};
|
||||
break;
|
||||
case ConformanceRequest.PayloadOneofCase.TextPayload:
|
||||
return new ConformanceResponse { Skipped =
|
||||
"CSharp doesn't support text format" };
|
||||
default:
|
||||
throw new Exception("Unsupported request payload: " + request.PayloadCase);
|
||||
}
|
||||
|
@ -115,7 +162,7 @@ namespace Google.Protobuf.Conformance
|
|||
case global::Conformance.WireFormat.Protobuf:
|
||||
return new ConformanceResponse { ProtobufPayload = message.ToByteString() };
|
||||
default:
|
||||
throw new Exception("Unsupported request output format: " + request.RequestedOutputFormat);
|
||||
return new ConformanceResponse { Skipped = "CSharp doesn't support text format" };
|
||||
}
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
|
|
Loading…
Reference in New Issue