Enable textproto conformance tests for "-0" and "-0F".

-0 should be treated as distinct from 0 when deciding it is default valued for implicit presence fields.

PiperOrigin-RevId: 632162352
pull/16782/head
Protobuf Team Bot 7 months ago committed by Copybara-Service
parent 1b06cefe33
commit 13caa08692
  1. 25
      conformance/text_format_conformance_suite.cc
  2. 20
      conformance/text_format_failure_list_python.txt
  3. 4
      conformance/text_format_failure_list_python_cpp.txt
  4. 4
      conformance/text_format_failure_list_python_upb.txt

@ -440,13 +440,11 @@ void TextFormatConformanceTestSuiteImpl<MessageType>::RunAllTests() {
absl::StrCat("FloatFieldLargerThanUint64", name_suffix), REQUIRED, absl::StrCat("FloatFieldLargerThanUint64", name_suffix), REQUIRED,
absl::StrCat("optional_float: 18446744073709551616", suffix)); absl::StrCat("optional_float: 18446744073709551616", suffix));
// https://protobuf.dev/reference/protobuf/textformat-spec/#literals says // https://protobuf.dev/reference/protobuf/textformat-spec/#literals says
// "-0" is a valid float literal. // "-0" is a valid float literal. -0 should be considered not the same as 0
// TODO: Figure out if this should count as not setting // when considering implicit presence, and so should round trip.
// presence or if -0 should be reflected back. RunValidTextFormatTest(absl::StrCat("FloatFieldNegativeZero", name_suffix),
// RunValidTextFormatTestWithExpected( REQUIRED,
// absl::StrCat("FloatFieldNegativeZero", name_suffix), REQUIRED, absl::StrCat("optional_float: -0", suffix));
// absl::StrCat("optional_float: -0", suffix),
// "" /* implicit presence, so zero means unset*/);
// https://protobuf.dev/reference/protobuf/textformat-spec/#literals says // https://protobuf.dev/reference/protobuf/textformat-spec/#literals says
// ".123", "-.123", ".123e2" are a valid float literal. // ".123", "-.123", ".123e2" are a valid float literal.
RunValidTextFormatTest(absl::StrCat("FloatFieldNoLeadingZero", name_suffix), RunValidTextFormatTest(absl::StrCat("FloatFieldNoLeadingZero", name_suffix),
@ -502,6 +500,19 @@ void TextFormatConformanceTestSuiteImpl<MessageType>::RunAllTests() {
RunValidTextFormatTestWithExpected( RunValidTextFormatTestWithExpected(
"DoubleFieldOverflowInfinityHugeExponent", REQUIRED, "DoubleFieldOverflowInfinityHugeExponent", REQUIRED,
"optional_double: 1e18446744073709551616", "optional_double: inf"); "optional_double: 1e18446744073709551616", "optional_double: inf");
RunValidTextFormatTestWithExpected(
"DoubleFieldLargeNegativeExponentParsesAsZero", REQUIRED,
"optional_double: 1e-18446744073709551616", "");
RunValidTextFormatTestWithExpected(
"NegDoubleFieldLargeNegativeExponentParsesAsNegZero", REQUIRED,
"optional_double: -1e-18446744073709551616", "optional_double: -0");
RunValidTextFormatTestWithExpected(
"FloatFieldLargeNegativeExponentParsesAsZero", REQUIRED,
"optional_float: 1e-50", "");
RunValidTextFormatTestWithExpected(
"NegFloatFieldLargeNegativeExponentParsesAsNegZero", REQUIRED,
"optional_float: -1e-50", "optional_float: -0");
// String literals x {Strings, Bytes} // String literals x {Strings, Bytes}
for (const auto& field_type : std::vector<std::string>{"String", "Bytes"}) { for (const auto& field_type : std::vector<std::string>{"String", "Bytes"}) {

@ -77,3 +77,23 @@ Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.ProtobufOutput
Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.TextFormatOutput Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.TextFormatOutput
Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.ProtobufOutput Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.ProtobufOutput
Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.TextFormatOutput Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.TextFormatOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldNegativeZero.ProtobufOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldNegativeZero.TextFormatOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldNegativeZero_F.ProtobufOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldNegativeZero_F.TextFormatOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldNegativeZero_f.ProtobufOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldNegativeZero_f.TextFormatOutput
Required.Editions_Proto3.TextFormatInput.NegDoubleFieldLargeNegativeExponentParsesAsNegZero.ProtobufOutput
Required.Editions_Proto3.TextFormatInput.NegDoubleFieldLargeNegativeExponentParsesAsNegZero.TextFormatOutput
Required.Editions_Proto3.TextFormatInput.NegFloatFieldLargeNegativeExponentParsesAsNegZero.ProtobufOutput
Required.Editions_Proto3.TextFormatInput.NegFloatFieldLargeNegativeExponentParsesAsNegZero.TextFormatOutput
Required.Proto3.TextFormatInput.FloatFieldNegativeZero.ProtobufOutput
Required.Proto3.TextFormatInput.FloatFieldNegativeZero.TextFormatOutput
Required.Proto3.TextFormatInput.FloatFieldNegativeZero_F.ProtobufOutput
Required.Proto3.TextFormatInput.FloatFieldNegativeZero_F.TextFormatOutput
Required.Proto3.TextFormatInput.FloatFieldNegativeZero_f.ProtobufOutput
Required.Proto3.TextFormatInput.FloatFieldNegativeZero_f.TextFormatOutput
Required.Proto3.TextFormatInput.NegDoubleFieldLargeNegativeExponentParsesAsNegZero.ProtobufOutput
Required.Proto3.TextFormatInput.NegDoubleFieldLargeNegativeExponentParsesAsNegZero.TextFormatOutput
Required.Proto3.TextFormatInput.NegFloatFieldLargeNegativeExponentParsesAsNegZero.ProtobufOutput
Required.Proto3.TextFormatInput.NegFloatFieldLargeNegativeExponentParsesAsNegZero.TextFormatOutput

@ -28,6 +28,8 @@ Required.Editions_Proto3.TextFormatInput.FloatFieldWithVeryPreciseNumber_F.Proto
Required.Editions_Proto3.TextFormatInput.FloatFieldWithVeryPreciseNumber_F.TextFormatOutput Required.Editions_Proto3.TextFormatInput.FloatFieldWithVeryPreciseNumber_F.TextFormatOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldZero_F.ProtobufOutput Required.Editions_Proto3.TextFormatInput.FloatFieldZero_F.ProtobufOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldZero_F.TextFormatOutput Required.Editions_Proto3.TextFormatInput.FloatFieldZero_F.TextFormatOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldNegativeZero_F.ProtobufOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldNegativeZero_F.TextFormatOutput
Required.Editions_Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.ProtobufOutput Required.Editions_Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.ProtobufOutput
Required.Editions_Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.TextFormatOutput Required.Editions_Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.TextFormatOutput
Required.Editions_Proto3.TextFormatInput.StringLiteralBasicEscapesString.ProtobufOutput Required.Editions_Proto3.TextFormatInput.StringLiteralBasicEscapesString.ProtobufOutput
@ -62,6 +64,8 @@ Required.Proto3.TextFormatInput.FloatFieldWithVeryPreciseNumber_F.ProtobufOutput
Required.Proto3.TextFormatInput.FloatFieldWithVeryPreciseNumber_F.TextFormatOutput Required.Proto3.TextFormatInput.FloatFieldWithVeryPreciseNumber_F.TextFormatOutput
Required.Proto3.TextFormatInput.FloatFieldZero_F.ProtobufOutput Required.Proto3.TextFormatInput.FloatFieldZero_F.ProtobufOutput
Required.Proto3.TextFormatInput.FloatFieldZero_F.TextFormatOutput Required.Proto3.TextFormatInput.FloatFieldZero_F.TextFormatOutput
Required.Proto3.TextFormatInput.FloatFieldNegativeZero_F.ProtobufOutput
Required.Proto3.TextFormatInput.FloatFieldNegativeZero_F.TextFormatOutput
Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.ProtobufOutput Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.ProtobufOutput
Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.TextFormatOutput Required.Proto3.TextFormatInput.StringLiteralBasicEscapesBytes.TextFormatOutput
Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.ProtobufOutput Required.Proto3.TextFormatInput.StringLiteralBasicEscapesString.ProtobufOutput

@ -15,6 +15,8 @@ Required.Editions_Proto3.TextFormatInput.FloatFieldNegative_F.ProtobufOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldNegative_F.TextFormatOutput Required.Editions_Proto3.TextFormatInput.FloatFieldNegative_F.TextFormatOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldNegativeNoLeadingZero_F.ProtobufOutput Required.Editions_Proto3.TextFormatInput.FloatFieldNegativeNoLeadingZero_F.ProtobufOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldNegativeNoLeadingZero_F.TextFormatOutput Required.Editions_Proto3.TextFormatInput.FloatFieldNegativeNoLeadingZero_F.TextFormatOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldNegativeZero_F.ProtobufOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldNegativeZero_F.TextFormatOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldNoLeadingZero_F.ProtobufOutput Required.Editions_Proto3.TextFormatInput.FloatFieldNoLeadingZero_F.ProtobufOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldNoLeadingZero_F.TextFormatOutput Required.Editions_Proto3.TextFormatInput.FloatFieldNoLeadingZero_F.TextFormatOutput
Required.Editions_Proto3.TextFormatInput.FloatFieldNoLeadingZeroWithExponent_F.ProtobufOutput Required.Editions_Proto3.TextFormatInput.FloatFieldNoLeadingZeroWithExponent_F.ProtobufOutput
@ -49,6 +51,8 @@ Required.Proto3.TextFormatInput.FloatFieldNegative_F.ProtobufOutput
Required.Proto3.TextFormatInput.FloatFieldNegative_F.TextFormatOutput Required.Proto3.TextFormatInput.FloatFieldNegative_F.TextFormatOutput
Required.Proto3.TextFormatInput.FloatFieldNegativeNoLeadingZero_F.ProtobufOutput Required.Proto3.TextFormatInput.FloatFieldNegativeNoLeadingZero_F.ProtobufOutput
Required.Proto3.TextFormatInput.FloatFieldNegativeNoLeadingZero_F.TextFormatOutput Required.Proto3.TextFormatInput.FloatFieldNegativeNoLeadingZero_F.TextFormatOutput
Required.Proto3.TextFormatInput.FloatFieldNegativeZero_F.ProtobufOutput
Required.Proto3.TextFormatInput.FloatFieldNegativeZero_F.TextFormatOutput
Required.Proto3.TextFormatInput.FloatFieldNoLeadingZero_F.ProtobufOutput Required.Proto3.TextFormatInput.FloatFieldNoLeadingZero_F.ProtobufOutput
Required.Proto3.TextFormatInput.FloatFieldNoLeadingZero_F.TextFormatOutput Required.Proto3.TextFormatInput.FloatFieldNoLeadingZero_F.TextFormatOutput
Required.Proto3.TextFormatInput.FloatFieldNoLeadingZeroWithExponent_F.ProtobufOutput Required.Proto3.TextFormatInput.FloatFieldNoLeadingZeroWithExponent_F.ProtobufOutput

Loading…
Cancel
Save