File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -566,4 +566,22 @@ mod tests {
566566 assert ! ( b. to_string( ) . contains( "bar=2;yellow" ) ) ;
567567 assert ! ( b. to_string( ) . contains( "foo=1;red;state=on" ) ) ;
568568 }
569+
570+ #[ test]
571+ fn replace_existing_key ( ) {
572+ let half_minus2: StringValue = ( 0 ..MAX_LEN_OF_ALL_PAIRS / 2 - 2 )
573+ . map ( |_| 'x' )
574+ . collect :: < String > ( )
575+ . into ( ) ;
576+
577+ let mut b = Baggage :: default ( ) ;
578+ b. insert ( "a" , half_minus2. clone ( ) ) ; // +1 for key
579+ b. insert ( "b" , half_minus2) ; // +1 for key
580+ b. insert ( "c" , StringValue :: from ( "." ) ) ; // total of 2 bytes
581+ assert ! ( b. get( "a" ) . is_some( ) ) ;
582+ assert ! ( b. get( "b" ) . is_some( ) ) ;
583+ assert ! ( b. get( "c" ) . is_some( ) ) ;
584+ assert ! ( b. insert( "c" , StringValue :: from( ".." ) ) . is_none( ) ) ; // exceeds MAX_LEN_OF_ALL_PAIRS
585+ assert_eq ! ( b. insert( "c" , StringValue :: from( "!" ) ) . unwrap( ) , "." . into( ) ) ; // replaces existing
586+ }
569587}
You can’t perform that action at this time.
0 commit comments