@@ -75,6 +75,9 @@ mod nesting;
7575#[ cfg( test) ]
7676mod recursive_oneof;
7777
78+ #[ cfg( test) ]
79+ mod groups;
80+
7881mod test_enum_named_option_value {
7982 include ! ( concat!( env!( "OUT_DIR" ) , "/myenum.optionn.rs" ) ) ;
8083}
@@ -106,10 +109,6 @@ pub mod oneof_attributes {
106109 include ! ( concat!( env!( "OUT_DIR" ) , "/foo.custom.one_of_attrs.rs" ) ) ;
107110}
108111
109- pub mod groups {
110- include ! ( concat!( env!( "OUT_DIR" ) , "/groups.rs" ) ) ;
111- }
112-
113112pub mod proto3 {
114113 pub mod presence {
115114 include ! ( concat!( env!( "OUT_DIR" ) , "/proto3.presence.rs" ) ) ;
@@ -263,8 +262,6 @@ mod tests {
263262
264263 use alloc:: collections:: { BTreeMap , BTreeSet } ;
265264 use alloc:: vec;
266- #[ cfg( not( feature = "std" ) ) ]
267- use alloc:: { boxed:: Box , string:: ToString } ;
268265
269266 use super :: * ;
270267
@@ -387,29 +384,6 @@ mod tests {
387384 set2. insert ( msg2. field ) ;
388385 }
389386
390- #[ test]
391- fn test_deep_nesting_group ( ) {
392- fn build_and_roundtrip ( depth : usize ) -> Result < ( ) , prost:: DecodeError > {
393- use crate :: groups:: { nested_group2:: OptionalGroup , NestedGroup2 } ;
394-
395- let mut a = NestedGroup2 :: default ( ) ;
396- for _ in 0 ..depth {
397- a = NestedGroup2 {
398- optionalgroup : Some ( Box :: new ( OptionalGroup {
399- nested_group : Some ( a) ,
400- } ) ) ,
401- } ;
402- }
403-
404- let mut buf = Vec :: new ( ) ;
405- a. encode ( & mut buf) . unwrap ( ) ;
406- NestedGroup2 :: decode ( buf. as_slice ( ) ) . map ( |_| ( ) )
407- }
408-
409- assert ! ( build_and_roundtrip( 50 ) . is_ok( ) ) ;
410- assert ! ( build_and_roundtrip( 51 ) . is_err( ) ) ;
411- }
412-
413387 #[ test]
414388 fn test_267_regression ( ) {
415389 // Checks that skip_field will error appropriately when given a big stack of StartGroup
@@ -426,83 +400,6 @@ mod tests {
426400 assert_eq ! ( msg. name, r#"["unknown"]"# ) ;
427401 }
428402
429- #[ test]
430- fn test_group ( ) {
431- // optional group
432- let msg1_bytes = & [ 0x0B , 0x10 , 0x20 , 0x0C ] ;
433-
434- let msg1 = groups:: Test1 {
435- groupa : Some ( groups:: test1:: GroupA { i2 : Some ( 32 ) } ) ,
436- } ;
437-
438- let mut bytes = Vec :: new ( ) ;
439- msg1. encode ( & mut bytes) . unwrap ( ) ;
440- assert_eq ! ( & bytes, msg1_bytes) ;
441-
442- // skip group while decoding
443- let data: & [ u8 ] = & [
444- 0x0B , // start group (tag=1)
445- 0x30 , 0x01 , // unused int32 (tag=6)
446- 0x2B , 0x30 , 0xFF , 0x01 , 0x2C , // unused group (tag=5)
447- 0x10 , 0x20 , // int32 (tag=2)
448- 0x0C , // end group (tag=1)
449- ] ;
450- assert_eq ! ( groups:: Test1 :: decode( data) , Ok ( msg1) ) ;
451-
452- // repeated group
453- let msg2_bytes: & [ u8 ] = & [
454- 0x20 , 0x40 , 0x2B , 0x30 , 0xFF , 0x01 , 0x2C , 0x2B , 0x30 , 0x01 , 0x2C , 0x38 , 0x64 ,
455- ] ;
456-
457- let msg2 = groups:: Test2 {
458- i14 : Some ( 64 ) ,
459- groupb : vec ! [
460- groups:: test2:: GroupB { i16 : Some ( 255 ) } ,
461- groups:: test2:: GroupB { i16 : Some ( 1 ) } ,
462- ] ,
463- i17 : Some ( 100 ) ,
464- } ;
465-
466- let mut bytes = Vec :: new ( ) ;
467- msg2. encode ( & mut bytes) . unwrap ( ) ;
468- assert_eq ! ( bytes. as_slice( ) , msg2_bytes) ;
469-
470- assert_eq ! ( groups:: Test2 :: decode( msg2_bytes) , Ok ( msg2) ) ;
471- }
472-
473- #[ test]
474- fn test_group_oneof ( ) {
475- let msg = groups:: OneofGroup {
476- i1 : Some ( 42 ) ,
477- field : Some ( groups:: oneof_group:: Field :: S2 ( "foo" . to_string ( ) ) ) ,
478- } ;
479- check_message ( & msg) ;
480-
481- let msg = groups:: OneofGroup {
482- i1 : Some ( 42 ) ,
483- field : Some ( groups:: oneof_group:: Field :: G ( groups:: oneof_group:: G {
484- i2 : None ,
485- s1 : "foo" . to_string ( ) ,
486- t1 : None ,
487- } ) ) ,
488- } ;
489- check_message ( & msg) ;
490-
491- let msg = groups:: OneofGroup {
492- i1 : Some ( 42 ) ,
493- field : Some ( groups:: oneof_group:: Field :: G ( groups:: oneof_group:: G {
494- i2 : Some ( 99 ) ,
495- s1 : "foo" . to_string ( ) ,
496- t1 : Some ( groups:: Test1 {
497- groupa : Some ( groups:: test1:: GroupA { i2 : None } ) ,
498- } ) ,
499- } ) ) ,
500- } ;
501- check_message ( & msg) ;
502-
503- check_message ( & groups:: OneofGroup :: default ( ) ) ;
504- }
505-
506403 #[ test]
507404 fn test_proto3_presence ( ) {
508405 let msg = proto3:: presence:: A {
0 commit comments