Browse Source

Add conformance test for binary string (#6415)

* Add conformance test for binary string

* Add failing tests to php failure list
Paul Yang 6 năm trước cách đây
mục cha
commit
eef87dd138

+ 10 - 1
conformance/binary_json_conformance_suite.cc

@@ -789,9 +789,18 @@ void BinaryAndJsonConformanceSuite::RunSuiteImpl() {
     {zz64(kInt64Max), std::to_string(kInt64Max)},
     {zz64(kInt64Max), std::to_string(kInt64Max)},
     {zz64(kInt64Min), std::to_string(kInt64Min)}
     {zz64(kInt64Min), std::to_string(kInt64Min)}
   });
   });
+  TestValidDataForType(FieldDescriptor::TYPE_STRING, {
+    {delim("Hello world!"), "\"Hello world!\""},
+    {delim("\'\"\?\\\a\b\f\n\r\t\v"),
+          "\"\x27\\\"\x3F\\\\\x07\x08\x0C\\n\x0D\x09\x0B\""},  // escape
+    {delim("谷歌"), "\"谷歌\""},  // Google in Chinese
+    {delim("\u8C37\u6B4C"), "\"谷歌\""},  // unicode escape
+    {delim("\u8c37\u6b4c"), "\"谷歌\""},  // lowercase unicode
+    {delim("\xF0\x9F\x98\x81"), "\"\xF0\x9F\x98\x81\""},  // emoji: 😁
+    {delim(""), "\"\""},
+  });
 
 
   // TODO(haberman):
   // TODO(haberman):
-  // TestValidDataForType(FieldDescriptor::TYPE_STRING
   // TestValidDataForType(FieldDescriptor::TYPE_GROUP
   // TestValidDataForType(FieldDescriptor::TYPE_GROUP
   // TestValidDataForType(FieldDescriptor::TYPE_MESSAGE
   // TestValidDataForType(FieldDescriptor::TYPE_MESSAGE
   // TestValidDataForType(FieldDescriptor::TYPE_BYTES
   // TestValidDataForType(FieldDescriptor::TYPE_BYTES

+ 2 - 0
conformance/failure_list_php_c.txt

@@ -42,3 +42,5 @@ Required.Proto3.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
 Required.Proto3.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
 Required.Proto3.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
 Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput
 Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput
 Required.Proto3.JsonInput.RejectTopLevelNull
 Required.Proto3.JsonInput.RejectTopLevelNull
+Required.Proto3.ProtobufInput.ValidDataRepeated.STRING.JsonOutput
+Required.Proto3.ProtobufInput.ValidDataRepeated.STRING.ProtobufOutput