File tree Expand file tree Collapse file tree
protobuf-test/src/common/v2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ //! Test when two messages are concatenated, singular fields are taken from the last one.
2+
3+ use super :: test_singular_concat_pb:: * ;
4+
5+ use protobuf_test_common:: * ;
6+
7+ #[ test]
8+ fn test_concat_bytes ( ) {
9+ let mut m = TestSingularConcat :: new ( ) ;
10+ m. set_b ( b"\xdd \xee " . to_vec ( ) ) ;
11+
12+ test_deserialize ( "12 03 aa bb cc 12 02 dd ee" , & m) ;
13+ }
14+
15+ #[ test]
16+ fn test_concat_string ( ) {
17+ let mut m = TestSingularConcat :: new ( ) ;
18+ m. set_s ( "\x61 \x62 " . to_string ( ) ) ;
19+
20+ test_deserialize ( "0a 03 21 22 23 0a 02 61 62" , & m) ;
21+ }
Original file line number Diff line number Diff line change 1+ syntax = "proto2" ;
2+
3+ package test_singular_concar ;
4+
5+ message TestSingularConcat {
6+ optional string s = 1 ;
7+ optional bytes b = 2 ;
8+ }
Original file line number Diff line number Diff line change @@ -701,8 +701,7 @@ impl<'a> CodedInputStream<'a> {
701701 }
702702
703703 pub fn read_string_into ( & mut self , target : & mut String ) -> ProtobufResult < ( ) > {
704- // assert string is empty, otherwize UTF-8 validation is too expensive
705- assert ! ( target. is_empty( ) ) ;
704+ target. clear ( ) ;
706705 // take target's buffer
707706 let mut vec = mem:: replace ( target, String :: new ( ) ) . into_bytes ( ) ;
708707 self . read_bytes_into ( & mut vec) ?;
You can’t perform that action at this time.
0 commit comments