protobuf/src/google/protobuf/lite_unittest.cc
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
30 
31 // Author: kenton@google.com (Kenton Varda)
32 
33 #include <iostream>
34 #include <string>
35 
36 #include <google/protobuf/stubs/logging.h>
37 #include <google/protobuf/stubs/common.h>
38 #include <google/protobuf/arena_test_util.h>
39 #include <google/protobuf/map_lite_test_util.h>
40 #include <google/protobuf/map_lite_unittest.pb.h>
41 #include <google/protobuf/test_util_lite.h>
42 #include <google/protobuf/unittest_lite.pb.h>
43 #include <google/protobuf/io/coded_stream.h>
44 #include <google/protobuf/io/zero_copy_stream.h>
45 #include <google/protobuf/io/zero_copy_stream_impl.h>
46 #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
47 #include <google/protobuf/wire_format_lite.h>
48 #include <gtest/gtest.h>
49 #include <google/protobuf/stubs/strutil.h>
50 
51 namespace google {
52 namespace protobuf {
53 
54 // Helper methods to test parsing merge behavior.
55 void ExpectMessageMerged(const unittest::TestAllTypesLite& message) {
56  EXPECT_EQ(message.optional_int32(), 3);
57  EXPECT_EQ(message.optional_int64(), 2);
58  EXPECT_EQ(message.optional_string(), "hello");
59 }
60 
61 void AssignParsingMergeMessages(unittest::TestAllTypesLite* msg1,
62  unittest::TestAllTypesLite* msg2,
63  unittest::TestAllTypesLite* msg3) {
64  msg1->set_optional_int32(1);
65  msg2->set_optional_int64(2);
66  msg3->set_optional_int32(3);
67  msg3->set_optional_string("hello");
68 }
69 
71  unittest::TestEmptyMessageLite* empty_message) {
72  protobuf_unittest::TestAllTypesLite message;
75  std::string data = message.SerializeAsString();
76  empty_message->ParseFromString(data);
77 }
78 
80  unittest::TestEmptyMessageLite* empty_message) {
81  protobuf_unittest::TestAllTypesLite message;
83  message.set_optional_int32(101);
84  message.set_optional_int64(102);
85  message.set_optional_uint32(103);
86  message.set_optional_uint64(104);
87  std::string data = message.SerializeAsString();
88  empty_message->ParseFromString(data);
89 }
90 
91 TEST(Lite, AllLite1) {
93 
94  {
95  protobuf_unittest::TestAllTypesLite message, message2, message3;
98  message2.CopyFrom(message);
99  data = message.SerializeAsString();
100  message3.ParseFromString(data);
106  message.Clear();
108  }
109 }
110 
111 TEST(Lite, AllLite2) {
113  {
114  protobuf_unittest::TestAllExtensionsLite message, message2, message3;
117  message2.CopyFrom(message);
118  std::string extensions_data = message.SerializeAsString();
119  message3.ParseFromString(extensions_data);
125  message.Clear();
127  }
128 }
129 
130 TEST(Lite, AllLite3) {
131  std::string data, packed_data;
132 
133  {
134  protobuf_unittest::TestPackedTypesLite message, message2, message3;
137  message2.CopyFrom(message);
138  packed_data = message.SerializeAsString();
139  message3.ParseFromString(packed_data);
145  message.Clear();
147  }
148 
149  {
150  protobuf_unittest::TestPackedExtensionsLite message, message2, message3;
153  message2.CopyFrom(message);
154  std::string packed_extensions_data = message.SerializeAsString();
155  EXPECT_EQ(packed_extensions_data, packed_data);
156  message3.ParseFromString(packed_extensions_data);
162  message.Clear();
164  }
165 }
166 
167 TEST(Lite, AllLite5) {
169 
170  {
171  // Test that if an optional or required message/group field appears multiple
172  // times in the input, they need to be merged.
173  unittest::TestParsingMergeLite::RepeatedFieldsGenerator generator;
174  unittest::TestAllTypesLite* msg1;
175  unittest::TestAllTypesLite* msg2;
176  unittest::TestAllTypesLite* msg3;
177 
178 #define ASSIGN_REPEATED_FIELD(FIELD) \
179  msg1 = generator.add_##FIELD(); \
180  msg2 = generator.add_##FIELD(); \
181  msg3 = generator.add_##FIELD(); \
182  AssignParsingMergeMessages(msg1, msg2, msg3)
183 
184  ASSIGN_REPEATED_FIELD(field1);
185  ASSIGN_REPEATED_FIELD(field2);
186  ASSIGN_REPEATED_FIELD(field3);
187  ASSIGN_REPEATED_FIELD(ext1);
188  ASSIGN_REPEATED_FIELD(ext2);
189 
190 #undef ASSIGN_REPEATED_FIELD
191 #define ASSIGN_REPEATED_GROUP(FIELD) \
192  msg1 = generator.add_##FIELD()->mutable_field1(); \
193  msg2 = generator.add_##FIELD()->mutable_field1(); \
194  msg3 = generator.add_##FIELD()->mutable_field1(); \
195  AssignParsingMergeMessages(msg1, msg2, msg3)
196 
197  ASSIGN_REPEATED_GROUP(group1);
198  ASSIGN_REPEATED_GROUP(group2);
199 
200 #undef ASSIGN_REPEATED_GROUP
201 
203  generator.SerializeToString(&buffer);
204  unittest::TestParsingMergeLite parsing_merge;
205  parsing_merge.ParseFromString(buffer);
206 
207  // Required and optional fields should be merged.
208  ExpectMessageMerged(parsing_merge.required_all_types());
209  ExpectMessageMerged(parsing_merge.optional_all_types());
211  parsing_merge.optionalgroup().optional_group_all_types());
212  ExpectMessageMerged(parsing_merge.GetExtension(
213  unittest::TestParsingMergeLite::optional_ext));
214 
215  // Repeated fields should not be merged.
216  EXPECT_EQ(parsing_merge.repeated_all_types_size(), 3);
217  EXPECT_EQ(parsing_merge.repeatedgroup_size(), 3);
218  EXPECT_EQ(parsing_merge.ExtensionSize(
219  unittest::TestParsingMergeLite::repeated_ext),
220  3);
221  }
222 }
223 
224 TEST(Lite, AllLite6) {
226 
227  // Test unknown fields support for lite messages.
228  {
229  protobuf_unittest::TestAllTypesLite message, message2;
230  protobuf_unittest::TestEmptyMessageLite empty_message;
233  data = message.SerializeAsString();
234  ASSERT_TRUE(empty_message.ParseFromString(data));
235  data.clear();
236  data = empty_message.SerializeAsString();
237  EXPECT_TRUE(message2.ParseFromString(data));
238  data = message2.SerializeAsString();
240  message.Clear();
242  }
243 }
244 
245 TEST(Lite, AllLite7) {
247 
248  {
249  protobuf_unittest::TestAllExtensionsLite message, message2;
250  protobuf_unittest::TestEmptyMessageLite empty_message;
253  data = message.SerializeAsString();
254  empty_message.ParseFromString(data);
255  data.clear();
256  data = empty_message.SerializeAsString();
257  message2.ParseFromString(data);
258  data = message2.SerializeAsString();
260  message.Clear();
262  }
263 }
264 
265 TEST(Lite, AllLite8) {
267 
268  {
269  protobuf_unittest::TestPackedTypesLite message, message2;
270  protobuf_unittest::TestEmptyMessageLite empty_message;
273  data = message.SerializeAsString();
274  empty_message.ParseFromString(data);
275  data.clear();
276  data = empty_message.SerializeAsString();
277  message2.ParseFromString(data);
278  data = message2.SerializeAsString();
280  message.Clear();
282  }
283 }
284 
285 TEST(Lite, AllLite9) {
287 
288  {
289  protobuf_unittest::TestPackedExtensionsLite message, message2;
290  protobuf_unittest::TestEmptyMessageLite empty_message;
293  data = message.SerializeAsString();
294  empty_message.ParseFromString(data);
295  data.clear();
296  data = empty_message.SerializeAsString();
297  message2.ParseFromString(data);
298  data = message2.SerializeAsString();
300  message.Clear();
302  }
303 }
304 
305 TEST(Lite, AllLite10) {
307 
308  {
309  // Test Unknown fields swap
310  protobuf_unittest::TestEmptyMessageLite empty_message, empty_message2;
313  data = empty_message.SerializeAsString();
314  std::string data2 = empty_message2.SerializeAsString();
315  empty_message.Swap(&empty_message2);
316  EXPECT_EQ(data, empty_message2.SerializeAsString());
317  EXPECT_EQ(data2, empty_message.SerializeAsString());
318  }
319 }
320 
321 TEST(Lite, AllLite11) {
323 
324  {
325  // Test unknown fields swap with self
326  protobuf_unittest::TestEmptyMessageLite empty_message;
328  data = empty_message.SerializeAsString();
329  empty_message.Swap(&empty_message);
330  EXPECT_EQ(data, empty_message.SerializeAsString());
331  }
332 }
333 
334 TEST(Lite, AllLite12) {
336 
337  {
338  // Test MergeFrom with unknown fields
339  protobuf_unittest::TestAllTypesLite message, message2;
340  protobuf_unittest::TestEmptyMessageLite empty_message, empty_message2;
341  message.set_optional_int32(101);
342  message.add_repeated_int32(201);
343  message.set_optional_nested_enum(unittest::TestAllTypesLite::BAZ);
344  message2.set_optional_int64(102);
345  message2.add_repeated_int64(202);
346  message2.set_optional_foreign_enum(unittest::FOREIGN_LITE_BAZ);
347 
348  data = message.SerializeAsString();
349  empty_message.ParseFromString(data);
350  data = message2.SerializeAsString();
351  empty_message2.ParseFromString(data);
352  message.MergeFrom(message2);
353  empty_message.MergeFrom(empty_message2);
354 
355  data = empty_message.SerializeAsString();
356  message2.ParseFromString(data);
357  // We do not compare the serialized output of a normal message and a lite
358  // message because the order of fields do not match. We convert lite message
359  // back into normal message, then compare.
360  EXPECT_EQ(message.SerializeAsString(), message2.SerializeAsString());
361  }
362 }
363 
364 TEST(Lite, AllLite13) {
366 
367  {
368  // Test unknown enum value
369  protobuf_unittest::TestAllTypesLite message;
371  {
372  io::StringOutputStream output_stream(&buffer);
373  io::CodedOutputStream coded_output(&output_stream);
375  protobuf_unittest::TestAllTypesLite::kOptionalNestedEnumFieldNumber,
377  coded_output.WriteVarint32(10);
379  protobuf_unittest::TestAllTypesLite::kRepeatedNestedEnumFieldNumber,
381  coded_output.WriteVarint32(20);
382  }
383  message.ParseFromString(buffer);
384  data = message.SerializeAsString();
386  }
387 }
388 
389 TEST(Lite, AllLite14) {
391 
392  {
393  // Test Clear with unknown fields
394  protobuf_unittest::TestEmptyMessageLite empty_message;
396  empty_message.Clear();
397  EXPECT_EQ(0, empty_message.unknown_fields().size());
398  }
399 }
400 
401 // Tests for map lite =============================================
402 
403 TEST(Lite, AllLite15) {
405 
406  {
407  // Accessors
408  protobuf_unittest::TestMapLite message;
409 
412 
415  }
416 }
417 
418 TEST(Lite, AllLite16) {
420 
421  {
422  // SetMapFieldsInitialized
423  protobuf_unittest::TestMapLite message;
424 
427  }
428 }
429 
430 TEST(Lite, AllLite17) {
432 
433  {
434  // Clear
435  protobuf_unittest::TestMapLite message;
436 
438  message.Clear();
440  }
441 }
442 
443 TEST(Lite, AllLite18) {
445 
446  {
447  // ClearMessageMap
448  protobuf_unittest::TestMessageMapLite message;
449 
450  // Creates a TestAllTypes with default value
451  TestUtilLite::ExpectClear((*message.mutable_map_int32_message())[0]);
452  }
453 }
454 
455 TEST(Lite, AllLite19) {
457 
458  {
459  // CopyFrom
460  protobuf_unittest::TestMapLite message1, message2;
461 
463  message2.CopyFrom(message1);
465 
466  // Copying from self should be a no-op.
467  message2.CopyFrom(message2);
469  }
470 }
471 
472 TEST(Lite, AllLite20) {
474 
475  {
476  // CopyFromMessageMap
477  protobuf_unittest::TestMessageMapLite message1, message2;
478 
479  (*message1.mutable_map_int32_message())[0].add_repeated_int32(100);
480  (*message2.mutable_map_int32_message())[0].add_repeated_int32(101);
481 
482  message1.CopyFrom(message2);
483 
484  // Checks repeated field is overwritten.
485  EXPECT_EQ(1, message1.map_int32_message().at(0).repeated_int32_size());
486  EXPECT_EQ(101, message1.map_int32_message().at(0).repeated_int32(0));
487  }
488 }
489 
490 TEST(Lite, AllLite21) {
492 
493  {
494  // SwapWithEmpty
495  protobuf_unittest::TestMapLite message1, message2;
496 
500 
501  message1.Swap(&message2);
504  }
505 }
506 
507 TEST(Lite, AllLite22) {
509 
510  {
511  // SwapWithSelf
512  protobuf_unittest::TestMapLite message;
513 
516 
517  message.Swap(&message);
519  }
520 }
521 
522 TEST(Lite, AllLite23) {
524 
525  {
526  // SwapWithOther
527  protobuf_unittest::TestMapLite message1, message2;
528 
532 
533  message1.Swap(&message2);
536  }
537 }
538 
539 TEST(Lite, AllLite24) {
541 
542  {
543  // CopyConstructor
544  protobuf_unittest::TestMapLite message1;
546 
547  protobuf_unittest::TestMapLite message2(message1);
549  }
550 }
551 
552 TEST(Lite, AllLite25) {
554 
555  {
556  // CopyAssignmentOperator
557  protobuf_unittest::TestMapLite message1;
559 
560  protobuf_unittest::TestMapLite message2;
561  message2 = message1;
563 
564  // Make sure that self-assignment does something sane.
565  message2.operator=(message2);
567  }
568 }
569 
570 TEST(Lite, AllLite26) {
572 
573  {
574  // NonEmptyMergeFrom
575  protobuf_unittest::TestMapLite message1, message2;
576 
578 
579  // This field will test merging into an empty spot.
580  (*message2.mutable_map_int32_int32())[1] = 1;
581  message1.mutable_map_int32_int32()->erase(1);
582 
583  // This tests overwriting.
584  (*message2.mutable_map_int32_double())[1] = 1;
585  (*message1.mutable_map_int32_double())[1] = 2;
586 
587  message1.MergeFrom(message2);
589  }
590 }
591 
592 TEST(Lite, AllLite27) {
594 
595  {
596  // MergeFromMessageMap
597  protobuf_unittest::TestMessageMapLite message1, message2;
598 
599  (*message1.mutable_map_int32_message())[0].add_repeated_int32(100);
600  (*message2.mutable_map_int32_message())[0].add_repeated_int32(101);
601 
602  message1.MergeFrom(message2);
603 
604  // Checks repeated field is overwritten.
605  EXPECT_EQ(1, message1.map_int32_message().at(0).repeated_int32_size());
606  EXPECT_EQ(101, message1.map_int32_message().at(0).repeated_int32(0));
607  }
608 }
609 
610 TEST(Lite, AllLite28) {
612 
613  {
614  // Test the generated SerializeWithCachedSizesToArray()
615  protobuf_unittest::TestMapLite message1, message2;
618  size_t size = message1.ByteSizeLong();
619  data.resize(size);
621  ::google::protobuf::uint8* end = message1.SerializeWithCachedSizesToArray(start);
622  EXPECT_EQ(size, end - start);
623  EXPECT_TRUE(message2.ParseFromString(data));
625  }
626 }
627 
628 TEST(Lite, AllLite29) {
630 
631  {
632  // Test the generated SerializeWithCachedSizes()
633  protobuf_unittest::TestMapLite message1, message2;
635  size_t size = message1.ByteSizeLong();
637  data.resize(size);
638  {
639  // Allow the output stream to buffer only one byte at a time.
640  io::ArrayOutputStream array_stream(::google::protobuf::string_as_array(&data), size, 1);
641  io::CodedOutputStream output_stream(&array_stream);
642  message1.SerializeWithCachedSizes(&output_stream);
643  EXPECT_FALSE(output_stream.HadError());
644  EXPECT_EQ(size, output_stream.ByteCount());
645  }
646  EXPECT_TRUE(message2.ParseFromString(data));
648  }
649 }
650 
651 
652 TEST(Lite, AllLite32) {
654 
655  {
656  // Proto2UnknownEnum
657  protobuf_unittest::TestEnumMapPlusExtraLite from;
658  (*from.mutable_known_map_field())[0] =
659  protobuf_unittest::E_PROTO2_MAP_ENUM_FOO_LITE;
660  (*from.mutable_unknown_map_field())[0] =
661  protobuf_unittest::E_PROTO2_MAP_ENUM_EXTRA_LITE;
663  from.SerializeToString(&data);
664 
665  protobuf_unittest::TestEnumMapLite to;
666  EXPECT_TRUE(to.ParseFromString(data));
667  EXPECT_EQ(0, to.unknown_map_field().size());
668  EXPECT_FALSE(to.mutable_unknown_fields()->empty());
669  ASSERT_EQ(1, to.known_map_field().size());
670  EXPECT_EQ(protobuf_unittest::PROTO2_MAP_ENUM_FOO_LITE,
671  to.known_map_field().at(0));
672 
673  data.clear();
674  from.Clear();
675  to.SerializeToString(&data);
676  EXPECT_TRUE(from.ParseFromString(data));
677  ASSERT_EQ(1, from.known_map_field().size());
678  EXPECT_EQ(protobuf_unittest::E_PROTO2_MAP_ENUM_FOO_LITE,
679  from.known_map_field().at(0));
680  ASSERT_EQ(1, from.unknown_map_field().size());
681  EXPECT_EQ(protobuf_unittest::E_PROTO2_MAP_ENUM_EXTRA_LITE,
682  from.unknown_map_field().at(0));
683  }
684 }
685 
686 TEST(Lite, AllLite33) {
688 
689  {
690  // StandardWireFormat
691  protobuf_unittest::TestMapLite message;
692  std::string data = "\x0A\x04\x08\x01\x10\x01";
693 
694  EXPECT_TRUE(message.ParseFromString(data));
695  ASSERT_EQ(1, message.map_int32_int32().size());
696  EXPECT_EQ(1, message.map_int32_int32().at(1));
697  }
698 }
699 
700 TEST(Lite, AllLite34) {
702 
703  {
704  // UnorderedWireFormat
705  protobuf_unittest::TestMapLite message;
706 
707  // put value before key in wire format
708  std::string data = "\x0A\x04\x10\x01\x08\x02";
709 
710  EXPECT_TRUE(message.ParseFromString(data));
711  ASSERT_EQ(1, message.map_int32_int32().size());
712  ASSERT_NE(message.map_int32_int32().find(2),
713  message.map_int32_int32().end());
714  EXPECT_EQ(1, message.map_int32_int32().at(2));
715  }
716 }
717 
718 TEST(Lite, AllLite35) {
720 
721  {
722  // DuplicatedKeyWireFormat
723  protobuf_unittest::TestMapLite message;
724 
725  // Two key fields in wire format
726  std::string data = "\x0A\x06\x08\x01\x08\x02\x10\x01";
727 
728  EXPECT_TRUE(message.ParseFromString(data));
729  ASSERT_EQ(1, message.map_int32_int32().size());
730  EXPECT_EQ(1, message.map_int32_int32().at(2));
731  }
732 }
733 
734 TEST(Lite, AllLite36) {
736 
737  {
738  // DuplicatedValueWireFormat
739  protobuf_unittest::TestMapLite message;
740 
741  // Two value fields in wire format
742  std::string data = "\x0A\x06\x08\x01\x10\x01\x10\x02";
743 
744  EXPECT_TRUE(message.ParseFromString(data));
745  ASSERT_EQ(1, message.map_int32_int32().size());
746  EXPECT_EQ(2, message.map_int32_int32().at(1));
747  }
748 }
749 
750 TEST(Lite, AllLite37) {
752 
753  {
754  // MissedKeyWireFormat
755  protobuf_unittest::TestMapLite message;
756 
757  // No key field in wire format
758  std::string data = "\x0A\x02\x10\x01";
759 
760  EXPECT_TRUE(message.ParseFromString(data));
761  ASSERT_EQ(1, message.map_int32_int32().size());
762  ASSERT_NE(message.map_int32_int32().find(0),
763  message.map_int32_int32().end());
764  EXPECT_EQ(1, message.map_int32_int32().at(0));
765  }
766 }
767 
768 TEST(Lite, AllLite38) {
770 
771  {
772  // MissedValueWireFormat
773  protobuf_unittest::TestMapLite message;
774 
775  // No value field in wire format
776  std::string data = "\x0A\x02\x08\x01";
777 
778  EXPECT_TRUE(message.ParseFromString(data));
779  ASSERT_EQ(1, message.map_int32_int32().size());
780  ASSERT_NE(message.map_int32_int32().find(1),
781  message.map_int32_int32().end());
782  EXPECT_EQ(0, message.map_int32_int32().at(1));
783  }
784 }
785 
786 TEST(Lite, AllLite39) {
788 
789  {
790  // UnknownFieldWireFormat
791  protobuf_unittest::TestMapLite message;
792 
793  // Unknown field in wire format
794  std::string data = "\x0A\x06\x08\x02\x10\x03\x18\x01";
795 
796  EXPECT_TRUE(message.ParseFromString(data));
797  ASSERT_EQ(1, message.map_int32_int32().size());
798  EXPECT_EQ(3, message.map_int32_int32().at(2));
799  }
800 }
801 
802 TEST(Lite, AllLite40) {
804 
805  {
806  // CorruptedWireFormat
807  protobuf_unittest::TestMapLite message;
808 
809  // corrupted data in wire format
810  std::string data = "\x0A\x06\x08\x02\x11\x03";
811 
812  EXPECT_FALSE(message.ParseFromString(data));
813  }
814 }
815 
816 TEST(Lite, AllLite41) {
818 
819  {
820  // IsInitialized
821  protobuf_unittest::TestRequiredMessageMapLite map_message;
822 
823  // Add an uninitialized message.
824  (*map_message.mutable_map_field())[0];
825  EXPECT_FALSE(map_message.IsInitialized());
826 
827  // Initialize uninitialized message
828  (*map_message.mutable_map_field())[0].set_a(0);
829  (*map_message.mutable_map_field())[0].set_b(0);
830  (*map_message.mutable_map_field())[0].set_c(0);
831  EXPECT_TRUE(map_message.IsInitialized());
832  }
833 }
834 
835 TEST(Lite, AllLite42) {
837 
838  {
839  // Check that adding more values to enum does not corrupt message
840  // when passed through an old client.
841  protobuf_unittest::V2MessageLite v2_message;
842  v2_message.set_int_field(800);
843  // Set enum field to the value not understood by the old client.
844  v2_message.set_enum_field(protobuf_unittest::V2_SECOND);
845  std::string v2_bytes = v2_message.SerializeAsString();
846 
847  protobuf_unittest::V1MessageLite v1_message;
848  v1_message.ParseFromString(v2_bytes);
849  EXPECT_TRUE(v1_message.IsInitialized());
850  EXPECT_EQ(v1_message.int_field(), v2_message.int_field());
851  // V1 client does not understand V2_SECOND value, so it discards it and
852  // uses default value instead.
853  EXPECT_EQ(v1_message.enum_field(), protobuf_unittest::V1_FIRST);
854 
855  // However, when re-serialized, it should preserve enum value.
856  std::string v1_bytes = v1_message.SerializeAsString();
857 
858  protobuf_unittest::V2MessageLite same_v2_message;
859  same_v2_message.ParseFromString(v1_bytes);
860 
861  EXPECT_EQ(v2_message.int_field(), same_v2_message.int_field());
862  EXPECT_EQ(v2_message.enum_field(), same_v2_message.enum_field());
863  }
864 }
865 
866 // Test that when parsing a oneof, we can successfully clear whatever already
867 // happened to be stored in the oneof.
868 TEST(Lite, AllLite43) {
869  protobuf_unittest::TestOneofParsingLite message1;
870 
871  message1.set_oneof_int32(17);
872  std::string serialized;
873  EXPECT_TRUE(message1.SerializeToString(&serialized));
874 
875  // Submessage
876  {
877  protobuf_unittest::TestOneofParsingLite message2;
878  message2.mutable_oneof_submessage();
879  io::CodedInputStream input_stream(
880  reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), serialized.size());
881  EXPECT_TRUE(message2.MergeFromCodedStream(&input_stream));
882  EXPECT_EQ(17, message2.oneof_int32());
883  }
884 
885  // String
886  {
887  protobuf_unittest::TestOneofParsingLite message2;
888  message2.set_oneof_string("string");
889  io::CodedInputStream input_stream(
890  reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), serialized.size());
891  EXPECT_TRUE(message2.MergeFromCodedStream(&input_stream));
892  EXPECT_EQ(17, message2.oneof_int32());
893  }
894 
895  // Bytes
896  {
897  protobuf_unittest::TestOneofParsingLite message2;
898  message2.set_oneof_bytes("bytes");
899  io::CodedInputStream input_stream(
900  reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()), serialized.size());
901  EXPECT_TRUE(message2.MergeFromCodedStream(&input_stream));
902  EXPECT_EQ(17, message2.oneof_int32());
903  }
904 }
905 
906 // Verify that we can successfully parse fields of various types within oneof
907 // fields. We also verify that we can parse the same data twice into the same
908 // message.
909 TEST(Lite, AllLite44) {
910  // Int32
911  {
912  protobuf_unittest::TestOneofParsingLite original;
913  original.set_oneof_int32(17);
914  std::string serialized;
915  EXPECT_TRUE(original.SerializeToString(&serialized));
916  protobuf_unittest::TestOneofParsingLite parsed;
917  for (int i = 0; i < 2; ++i) {
918  io::CodedInputStream input_stream(
919  reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()),
920  serialized.size());
921  EXPECT_TRUE(parsed.MergeFromCodedStream(&input_stream));
922  EXPECT_EQ(17, parsed.oneof_int32());
923  }
924  }
925 
926  // Submessage
927  {
928  protobuf_unittest::TestOneofParsingLite original;
929  original.mutable_oneof_submessage()->set_optional_int32(5);
930  std::string serialized;
931  EXPECT_TRUE(original.SerializeToString(&serialized));
932  protobuf_unittest::TestOneofParsingLite parsed;
933  for (int i = 0; i < 2; ++i) {
934  io::CodedInputStream input_stream(
935  reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()),
936  serialized.size());
937  EXPECT_TRUE(parsed.MergeFromCodedStream(&input_stream));
938  EXPECT_EQ(5, parsed.oneof_submessage().optional_int32());
939  }
940  }
941 
942  // String
943  {
944  protobuf_unittest::TestOneofParsingLite original;
945  original.set_oneof_string("string");
946  std::string serialized;
947  EXPECT_TRUE(original.SerializeToString(&serialized));
948  protobuf_unittest::TestOneofParsingLite parsed;
949  for (int i = 0; i < 2; ++i) {
950  io::CodedInputStream input_stream(
951  reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()),
952  serialized.size());
953  EXPECT_TRUE(parsed.MergeFromCodedStream(&input_stream));
954  EXPECT_EQ("string", parsed.oneof_string());
955  }
956  }
957 
958  // Bytes
959  {
960  protobuf_unittest::TestOneofParsingLite original;
961  original.set_oneof_bytes("bytes");
962  std::string serialized;
963  EXPECT_TRUE(original.SerializeToString(&serialized));
964  protobuf_unittest::TestOneofParsingLite parsed;
965  for (int i = 0; i < 2; ++i) {
966  io::CodedInputStream input_stream(
967  reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()),
968  serialized.size());
969  EXPECT_TRUE(parsed.MergeFromCodedStream(&input_stream));
970  EXPECT_EQ("bytes", parsed.oneof_bytes());
971  }
972  }
973 
974  // Enum
975  {
976  protobuf_unittest::TestOneofParsingLite original;
977  original.set_oneof_enum(protobuf_unittest::V2_SECOND);
978  std::string serialized;
979  EXPECT_TRUE(original.SerializeToString(&serialized));
980  protobuf_unittest::TestOneofParsingLite parsed;
981  for (int i = 0; i < 2; ++i) {
982  io::CodedInputStream input_stream(
983  reinterpret_cast<const ::google::protobuf::uint8*>(serialized.data()),
984  serialized.size());
985  EXPECT_TRUE(parsed.MergeFromCodedStream(&input_stream));
986  EXPECT_EQ(protobuf_unittest::V2_SECOND, parsed.oneof_enum());
987  }
988  }
989 
990  std::cout << "PASS" << std::endl;
991 }
992 
993 TEST(Lite, AllLite45) {
994  // Test unknown fields are not discarded upon parsing.
995  std::string data = "\20\1"; // varint 1 with field number 2
996 
997  protobuf_unittest::ForeignMessageLite a;
998  EXPECT_TRUE(a.ParseFromString(data));
999  io::CodedInputStream input_stream(
1000  reinterpret_cast<const ::google::protobuf::uint8*>(data.data()), data.size());
1001  EXPECT_TRUE(a.MergePartialFromCodedStream(&input_stream));
1002 
1003  std::string serialized = a.SerializeAsString();
1004  EXPECT_EQ(serialized.substr(0, 2), data);
1005  EXPECT_EQ(serialized.substr(2), data);
1006 }
1007 
1008 // The following two tests check for wire compatibility between packed and
1009 // unpacked repeated fields. There used to be a bug in the generated parsing
1010 // code that caused us to calculate the highest possible tag number without
1011 // taking into account that a repeated field might not be in the packed (or
1012 // unpacked) state we expect. These tests specifically check for that issue by
1013 // making sure we can parse repeated fields when the tag is higher than we would
1014 // expect.
1015 TEST(Lite, AllLite46) {
1016  protobuf_unittest::PackedInt32 packed;
1017  packed.add_repeated_int32(42);
1018  std::string serialized;
1019  ASSERT_TRUE(packed.SerializeToString(&serialized));
1020 
1021  protobuf_unittest::NonPackedInt32 non_packed;
1022  ASSERT_TRUE(non_packed.ParseFromString(serialized));
1023  ASSERT_EQ(1, non_packed.repeated_int32_size());
1024  EXPECT_EQ(42, non_packed.repeated_int32(0));
1025 }
1026 
1027 TEST(Lite, AllLite47) {
1028  protobuf_unittest::NonPackedFixed32 non_packed;
1029  non_packed.add_repeated_fixed32(42);
1030  std::string serialized;
1031  ASSERT_TRUE(non_packed.SerializeToString(&serialized));
1032 
1033  protobuf_unittest::PackedFixed32 packed;
1034  ASSERT_TRUE(packed.ParseFromString(serialized));
1035  ASSERT_EQ(1, packed.repeated_fixed32_size());
1036  EXPECT_EQ(42, packed.repeated_fixed32(0));
1037 }
1038 
1039 TEST(Lite, MapCrash) {
1040  // See b/113635730
1041  Arena arena;
1042  auto msg = Arena::CreateMessage<protobuf_unittest::TestMapLite>(&arena);
1043  // Payload for the map<string, Enum> with a enum varint that's longer >
1044  // 10 bytes. This causes a parse fail and a subsequent delete. field 16
1045  // (map<int32, MapEnumLite>) tag = 128+2 = \202 \1
1046  // 13 long \15
1047  // int32 key = 1 (\10 \1)
1048  // MapEnumLite value = too long varint (parse error)
1049  EXPECT_FALSE(msg->ParseFromString(
1050  "\202\1\15\10\1\200\200\200\200\200\200\200\200\200\200\1"));
1051 }
1052 
1053 TEST(Lite, CorrectEnding) {
1054  protobuf_unittest::TestAllTypesLite msg;
1055  {
1056  // All proto wireformat parsers should act the same on parsing data in as
1057  // much as it concerns the parsing, ie. not the interpretation of the data.
1058  // TestAllTypesLite is not a group inside another message. So in practice
1059  // will not encounter an end-group tag. However the parser should behave
1060  // like any wire format parser should.
1061  static const char kWireFormat[] = "\204\1";
1062  io::CodedInputStream cis(reinterpret_cast<const uint8*>(kWireFormat), 2);
1063  // The old CodedInputStream parser got an optimization (ReadTagNoLastTag)
1064  // for non-group messages (like TestAllTypesLite) which made it not accept
1065  // end-group. This is not a real big deal, but I think going forward its
1066  // good to have all parse loops behave 'exactly' the same.
1067  EXPECT_TRUE(msg.MergePartialFromCodedStream(&cis));
1068  EXPECT_FALSE(cis.ConsumedEntireMessage());
1069  EXPECT_TRUE(cis.LastTagWas(132));
1070  }
1071  {
1072  // This is an incomplete end-group tag. This should be a genuine parse
1073  // failure.
1074  static const char kWireFormat[] = "\214";
1075  io::CodedInputStream cis(reinterpret_cast<const uint8*>(kWireFormat), 1);
1076  // Unfortunately the old parser detects a parse error in ReadTag and returns
1077  // 0 (as it states 0 is an invalid tag). However 0 is not an invalid tag
1078  // as it can be used to terminate the stream, so this returns true.
1079  EXPECT_FALSE(msg.MergePartialFromCodedStream(&cis));
1080  }
1081 }
1082 
1083 TEST(Lite, DebugString) {
1084  protobuf_unittest::TestAllTypesLite message1, message2;
1085  EXPECT_TRUE(HasPrefixString(message1.DebugString(), "MessageLite at 0x"));
1086  EXPECT_TRUE(HasPrefixString(message2.DebugString(), "MessageLite at 0x"));
1087 
1088  // DebugString() and ShortDebugString() are the same for now.
1089  EXPECT_EQ(message1.DebugString(), message1.ShortDebugString());
1090 
1091  // Even identical lite protos should have different DebugString() output. Part
1092  // of the reason for including the memory address is so that we get some
1093  // non-determinism, which should make it easier for us to change the output
1094  // later without breaking any code.
1095  EXPECT_NE(message1.DebugString(), message2.DebugString());
1096 }
1097 
1098 TEST(Lite, EnumValueToName) {
1099  EXPECT_EQ("FOREIGN_LITE_FOO", protobuf_unittest::ForeignEnumLite_Name(
1100  protobuf_unittest::FOREIGN_LITE_FOO));
1101  EXPECT_EQ("FOREIGN_LITE_BAR", protobuf_unittest::ForeignEnumLite_Name(
1102  protobuf_unittest::FOREIGN_LITE_BAR));
1103  EXPECT_EQ("FOREIGN_LITE_BAZ", protobuf_unittest::ForeignEnumLite_Name(
1104  protobuf_unittest::FOREIGN_LITE_BAZ));
1105  EXPECT_EQ("", protobuf_unittest::ForeignEnumLite_Name(0));
1106  EXPECT_EQ("", protobuf_unittest::ForeignEnumLite_Name(999));
1107 }
1108 
1109 TEST(Lite, NestedEnumValueToName) {
1110  EXPECT_EQ("FOO", protobuf_unittest::TestAllTypesLite::NestedEnum_Name(
1111  protobuf_unittest::TestAllTypesLite::FOO));
1112  EXPECT_EQ("BAR", protobuf_unittest::TestAllTypesLite::NestedEnum_Name(
1113  protobuf_unittest::TestAllTypesLite::BAR));
1114  EXPECT_EQ("BAZ", protobuf_unittest::TestAllTypesLite::NestedEnum_Name(
1115  protobuf_unittest::TestAllTypesLite::BAZ));
1116  EXPECT_EQ("", protobuf_unittest::TestAllTypesLite::NestedEnum_Name(0));
1117  EXPECT_EQ("", protobuf_unittest::TestAllTypesLite::NestedEnum_Name(999));
1118 }
1119 
1120 TEST(Lite, EnumNameToValue) {
1121  protobuf_unittest::ForeignEnumLite value;
1122 
1123  ASSERT_TRUE(
1124  protobuf_unittest::ForeignEnumLite_Parse("FOREIGN_LITE_FOO", &value));
1125  EXPECT_EQ(protobuf_unittest::FOREIGN_LITE_FOO, value);
1126 
1127  ASSERT_TRUE(
1128  protobuf_unittest::ForeignEnumLite_Parse("FOREIGN_LITE_BAR", &value));
1129  EXPECT_EQ(protobuf_unittest::FOREIGN_LITE_BAR, value);
1130 
1131  ASSERT_TRUE(
1132  protobuf_unittest::ForeignEnumLite_Parse("FOREIGN_LITE_BAZ", &value));
1133  EXPECT_EQ(protobuf_unittest::FOREIGN_LITE_BAZ, value);
1134 
1135  // Non-existent values
1136  EXPECT_FALSE(protobuf_unittest::ForeignEnumLite_Parse("E", &value));
1137  EXPECT_FALSE(
1138  protobuf_unittest::ForeignEnumLite_Parse("FOREIGN_LITE_C", &value));
1139  EXPECT_FALSE(protobuf_unittest::ForeignEnumLite_Parse("G", &value));
1140 }
1141 
1142 TEST(Lite, NestedEnumNameToValue) {
1143  protobuf_unittest::TestAllTypesLite::NestedEnum value;
1144 
1145  ASSERT_TRUE(
1146  protobuf_unittest::TestAllTypesLite::NestedEnum_Parse("FOO", &value));
1147  EXPECT_EQ(protobuf_unittest::TestAllTypesLite::FOO, value);
1148 
1149  ASSERT_TRUE(
1150  protobuf_unittest::TestAllTypesLite::NestedEnum_Parse("BAR", &value));
1151  EXPECT_EQ(protobuf_unittest::TestAllTypesLite::BAR, value);
1152 
1153  ASSERT_TRUE(
1154  protobuf_unittest::TestAllTypesLite::NestedEnum_Parse("BAZ", &value));
1155  EXPECT_EQ(protobuf_unittest::TestAllTypesLite::BAZ, value);
1156 
1157  // Non-existent values
1158  EXPECT_FALSE(
1159  protobuf_unittest::TestAllTypesLite::NestedEnum_Parse("A", &value));
1160  EXPECT_FALSE(
1161  protobuf_unittest::TestAllTypesLite::NestedEnum_Parse("C", &value));
1162  EXPECT_FALSE(
1163  protobuf_unittest::TestAllTypesLite::NestedEnum_Parse("G", &value));
1164 }
1165 
1166 TEST(Lite, AliasedEnum) {
1167  // Enums with allow_alias = true can have multiple entries with the same
1168  // value.
1169  EXPECT_EQ("FOO1", protobuf_unittest::DupEnum::TestEnumWithDupValueLite_Name(
1170  protobuf_unittest::DupEnum::FOO1));
1171  EXPECT_EQ("FOO1", protobuf_unittest::DupEnum::TestEnumWithDupValueLite_Name(
1172  protobuf_unittest::DupEnum::FOO2));
1173  EXPECT_EQ("BAR1", protobuf_unittest::DupEnum::TestEnumWithDupValueLite_Name(
1174  protobuf_unittest::DupEnum::BAR1));
1175  EXPECT_EQ("BAR1", protobuf_unittest::DupEnum::TestEnumWithDupValueLite_Name(
1176  protobuf_unittest::DupEnum::BAR2));
1177  EXPECT_EQ("BAZ", protobuf_unittest::DupEnum::TestEnumWithDupValueLite_Name(
1178  protobuf_unittest::DupEnum::BAZ));
1179  EXPECT_EQ("", protobuf_unittest::DupEnum::TestEnumWithDupValueLite_Name(999));
1180 
1181  protobuf_unittest::DupEnum::TestEnumWithDupValueLite value;
1182  ASSERT_TRUE(
1183  protobuf_unittest::DupEnum::TestEnumWithDupValueLite_Parse("FOO1", &value));
1184  EXPECT_EQ(protobuf_unittest::DupEnum::FOO1, value);
1185 
1186  value = static_cast<protobuf_unittest::DupEnum::TestEnumWithDupValueLite>(0);
1187  ASSERT_TRUE(
1188  protobuf_unittest::DupEnum::TestEnumWithDupValueLite_Parse("FOO2", &value));
1189  EXPECT_EQ(protobuf_unittest::DupEnum::FOO2, value);
1190 }
1191 
1192 
1193 TEST(Lite, CodedInputStreamRollback) {
1194  {
1195  protobuf_unittest::TestAllTypesLite m;
1196  m.set_optional_bytes(std::string(30, 'a'));
1197  std::string serialized = m.SerializeAsString();
1198  serialized += '\014';
1199  serialized += std::string(3, ' ');
1200  io::ArrayInputStream is(serialized.data(), serialized.size(),
1201  serialized.size() - 6);
1202  {
1203  io::CodedInputStream cis(&is);
1204  m.Clear();
1205  m.MergePartialFromCodedStream(&cis);
1206  EXPECT_TRUE(cis.LastTagWas(12));
1208  // Should leave is with 3 spaces;
1209  }
1210  const void* data;
1211  int size;
1212  ASSERT_TRUE(is.Next(&data, &size));
1213  ASSERT_EQ(size, 3);
1214  EXPECT_EQ(memcmp(data, " ", 3), 0);
1215  }
1216  {
1217  protobuf_unittest::TestPackedTypesLite m;
1218  constexpr int kCount = 30;
1219  for (int i = 0; i < kCount; i++) m.add_packed_fixed32(i);
1220  std::string serialized = m.SerializeAsString();
1221  serialized += '\014';
1222  serialized += std::string(3, ' ');
1223  // Buffer breaks in middle of a fixed32.
1224  io::ArrayInputStream is(serialized.data(), serialized.size(),
1225  serialized.size() - 7);
1226  {
1227  io::CodedInputStream cis(&is);
1228  m.Clear();
1229  m.MergePartialFromCodedStream(&cis);
1230  EXPECT_TRUE(cis.LastTagWas(12));
1232  // Should leave is with 3 spaces;
1233  }
1234  ASSERT_EQ(m.packed_fixed32_size(), kCount);
1235  for (int i = 0; i < kCount; i++) EXPECT_EQ(m.packed_fixed32(i), i);
1236  const void* data;
1237  int size;
1238  ASSERT_TRUE(is.Next(&data, &size));
1239  ASSERT_EQ(size, 3);
1240  EXPECT_EQ(memcmp(data, " ", 3), 0);
1241  }
1242  {
1243  protobuf_unittest::TestPackedTypesLite m;
1244  constexpr int kCount = 30;
1245  // Make sure we output 2 byte varints
1246  for (int i = 0; i < kCount; i++) m.add_packed_fixed32(128 + i);
1247  std::string serialized = m.SerializeAsString();
1248  serialized += '\014';
1249  serialized += std::string(3, ' ');
1250  // Buffer breaks in middle of a 2 byte varint.
1251  io::ArrayInputStream is(serialized.data(), serialized.size(),
1252  serialized.size() - 5);
1253  {
1254  io::CodedInputStream cis(&is);
1255  m.Clear();
1256  m.MergePartialFromCodedStream(&cis);
1257  EXPECT_TRUE(cis.LastTagWas(12));
1259  // Should leave is with 3 spaces;
1260  }
1261  ASSERT_EQ(m.packed_fixed32_size(), kCount);
1262  for (int i = 0; i < kCount; i++) EXPECT_EQ(m.packed_fixed32(i), i + 128);
1263  const void* data;
1264  int size;
1265  ASSERT_TRUE(is.Next(&data, &size));
1266  ASSERT_EQ(size, 3);
1267  EXPECT_EQ(memcmp(data, " ", 3), 0);
1268  }
1269 }
1270 
1271 } // namespace protobuf
1272 } // namespace google
EXPECT_FALSE
#define EXPECT_FALSE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1970
ASSERT_NE
#define ASSERT_NE(val1, val2)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2060
google::protobuf::TestUtilLite::SetAllFields
static void SetAllFields(unittest::TestAllTypesLite *message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:45
google::protobuf::value
const Descriptor::ReservedRange value
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1954
google::protobuf::TestUtilLite::ExpectExtensionsClear
static void ExpectExtensionsClear(const unittest::TestAllExtensionsLite &message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:1349
ASSIGN_REPEATED_GROUP
#define ASSIGN_REPEATED_GROUP(FIELD)
google::protobuf::TestUtilLite::ExpectPackedFieldsModified
static void ExpectPackedFieldsModified(const unittest::TestPackedTypesLite &message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:752
google::protobuf::TestUtilLite::ModifyPackedExtensions
static void ModifyPackedExtensions(unittest::TestPackedExtensionsLite *message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:1775
google::protobuf::uint8
uint8_t uint8
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:153
google::protobuf::TestUtilLite::SetPackedExtensions
static void SetPackedExtensions(unittest::TestPackedExtensionsLite *message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:1738
Arena
Definition: arena.c:39
DebugString
std::string DebugString(const google::protobuf::Message &message)
Definition: bloaty/tests/test.h:60
google::protobuf::MapLiteTestUtil::SetMapFields
static void SetMapFields(protobuf_unittest::TestMapLite *message)
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
google::protobuf::TestUtilLite::ExpectPackedExtensionsClear
static void ExpectPackedExtensionsClear(const unittest::TestPackedExtensionsLite &message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:1873
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
google::protobuf::MapLiteTestUtil::ExpectClear
static void ExpectClear(const protobuf_unittest::TestMapLite &message)
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
to
size_t to
Definition: abseil-cpp/absl/container/internal/layout_test.cc:1385
google::protobuf::TestUtilLite::ExpectAllExtensionsSet
static void ExpectAllExtensionsSet(const unittest::TestAllExtensionsLite &message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:996
google::protobuf::SetAllTypesInEmptyMessageUnknownFields
void SetAllTypesInEmptyMessageUnknownFields(unittest::TestEmptyMessageLite *empty_message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/lite_unittest.cc:68
google::protobuf::ExpectMessageMerged
void ExpectMessageMerged(const unittest::TestAllTypesLite &message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/lite_unittest.cc:53
message
char * message
Definition: libuv/docs/code/tty-gravity/main.c:12
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
EXPECT_EQ
#define EXPECT_EQ(a, b)
Definition: iomgr/time_averaged_stats_test.cc:27
google::protobuf::TestUtilLite::ModifyRepeatedExtensions
static void ModifyRepeatedExtensions(unittest::TestAllExtensionsLite *message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:955
grpc::protobuf::io::StringOutputStream
GRPC_CUSTOM_STRINGOUTPUTSTREAM StringOutputStream
Definition: src/compiler/config.h:56
from
size_t from
Definition: abseil-cpp/absl/container/internal/layout_test.cc:1384
start
static uint64_t start
Definition: benchmark-pound.c:74
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
google::protobuf::MapLiteTestUtil::SetMapFieldsInitialized
static void SetMapFieldsInitialized(protobuf_unittest::TestMapLite *message)
EXPECT_NE
#define EXPECT_NE(val1, val2)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2028
google::protobuf::TestUtilLite::ExpectPackedFieldsSet
static void ExpectPackedFieldsSet(const unittest::TestPackedTypesLite &message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:681
google::protobuf::io::CodedInputStream::ConsumedEntireMessage
bool ConsumedEntireMessage()
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1424
google::protobuf::MapLiteTestUtil::ExpectMapFieldsSet
static void ExpectMapFieldsSet(const protobuf_unittest::TestMapLite &message)
grpc::protobuf::io::CodedInputStream
GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream
Definition: include/grpcpp/impl/codegen/config_protobuf.h:102
google::protobuf::io::CodedInputStream::LastTagWas
bool LastTagWas(uint32 expected)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1420
google::protobuf::TestUtilLite::ModifyPackedFields
static void ModifyPackedFields(unittest::TestPackedTypesLite *message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:662
google::protobuf::TestUtilLite::ExpectClear
static void ExpectClear(const unittest::TestAllTypesLite &message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:394
google::protobuf::io::ArrayInputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h:66
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
google::protobuf::TEST
TEST(ArenaTest, ArenaConstructable)
Definition: bloaty/third_party/protobuf/src/google/protobuf/arena_unittest.cc:156
grpc::protobuf::io::CodedOutputStream
GRPC_CUSTOM_CODEDOUTPUTSTREAM CodedOutputStream
Definition: src/compiler/config.h:55
buffer
char buffer[1024]
Definition: libuv/docs/code/idle-compute/main.c:8
google::protobuf.internal::WireFormatLite::WIRETYPE_VARINT
@ WIRETYPE_VARINT
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:102
google::protobuf::string_as_array
char * string_as_array(string *str)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/stl_util.h:63
google::protobuf::TestUtilLite::SetAllExtensions
static void SetAllExtensions(unittest::TestAllExtensionsLite *message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:809
google::protobuf::HasPrefixString
bool HasPrefixString(const string &str, const string &prefix)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.h:115
msg
std::string msg
Definition: client_interceptors_end2end_test.cc:372
google::protobuf::MapLiteTestUtil::ModifyMapFields
static void ModifyMapFields(protobuf_unittest::TestMapLite *message)
google::protobuf::AssignParsingMergeMessages
void AssignParsingMergeMessages(unittest::TestAllTypesLite *msg1, unittest::TestAllTypesLite *msg2, unittest::TestAllTypesLite *msg3)
Definition: bloaty/third_party/protobuf/src/google/protobuf/lite_unittest.cc:59
google::protobuf::SetSomeTypesInEmptyMessageUnknownFields
void SetSomeTypesInEmptyMessageUnknownFields(unittest::TestEmptyMessageLite *empty_message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/lite_unittest.cc:77
google::protobuf::io::ArrayInputStream::Next
bool Next(const void **data, int *size) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc:65
google::protobuf::TestUtilLite::ExpectPackedExtensionsSet
static void ExpectPackedExtensionsSet(const unittest::TestPackedExtensionsLite &message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:1796
google::protobuf::TestUtilLite::ExpectPackedClear
static void ExpectPackedClear(const unittest::TestPackedTypesLite &message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:731
google::protobuf.internal::WireFormatLite::WriteTag
static PROTOBUF_ALWAYS_INLINE void WriteTag(int field_number, WireType type, io::CodedOutputStream *output)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:1289
google::protobuf::TestUtilLite::ExpectPackedExtensionsModified
static void ExpectPackedExtensionsModified(const unittest::TestPackedExtensionsLite &message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:1893
google::protobuf::MapLiteTestUtil::ExpectMapFieldsModified
static void ExpectMapFieldsModified(const protobuf_unittest::TestMapLite &message)
google::protobuf::TestUtilLite::ModifyRepeatedFields
static void ModifyRepeatedFields(unittest::TestAllTypesLite *message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:162
google::protobuf::MapLiteTestUtil::ExpectMapFieldsSetInitialized
static void ExpectMapFieldsSetInitialized(const protobuf_unittest::TestMapLite &message)
google::protobuf::io::CodedInputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:180
ASSERT_TRUE
#define ASSERT_TRUE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1973
google::protobuf::TestUtilLite::ExpectRepeatedFieldsModified
static void ExpectRepeatedFieldsModified(const unittest::TestAllTypesLite &message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:539
google::protobuf::TestUtilLite::ExpectAllFieldsSet
static void ExpectAllFieldsSet(const unittest::TestAllTypesLite &message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:193
EXPECT_TRUE
#define EXPECT_TRUE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1967
google::protobuf::TestUtilLite::ExpectRepeatedExtensionsModified
static void ExpectRepeatedExtensionsModified(const unittest::TestAllExtensionsLite &message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:1570
google::protobuf::TestUtilLite::SetPackedFields
static void SetPackedFields(unittest::TestPackedTypesLite *message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/test_util_lite.cc:628
ASSIGN_REPEATED_FIELD
#define ASSIGN_REPEATED_FIELD(FIELD)
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
regress.m
m
Definition: regress/regress.py:25
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
ASSERT_EQ
#define ASSERT_EQ(val1, val2)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2056


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:15