File tree Expand file tree Collapse file tree 1 file changed +30
-2
lines changed
Expand file tree Collapse file tree 1 file changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -2382,8 +2382,36 @@ mod tests {
23822382 }
23832383 _ => panic ! ( "buffering_msg.view() is not a MessageView::Buffering(_)" ) ,
23842384 }
2385+ }
23852386
2386- // TODO: add a tests for messages with and without arguments with an extra-field
2387- // and condition it to the "v1_14" feature
2387+ #[ cfg( feature = "v1_14" ) ]
2388+ #[ test]
2389+ fn test_other_fields ( ) {
2390+ let eos_msg = Message :: new_eos ( )
2391+ . other_fields ( & [ ( "extra-field" , & true ) ] )
2392+ . seqnum ( Seqnum ( 1 ) )
2393+ . build ( ) ;
2394+ match eos_msg. view ( ) {
2395+ MessageView :: Eos ( eos_msg) => {
2396+ assert_eq ! ( eos_msg. get_seqnum( ) , Seqnum ( 1 ) ) ;
2397+ if let Some ( other_fields) = eos_msg. get_structure ( ) {
2398+ assert ! ( other_fields. has_field( "extra-field" ) ) ;
2399+ }
2400+ }
2401+ _ => panic ! ( "eos_msg.view() is not a MessageView::Eos(_)" ) ,
2402+ }
2403+
2404+ let buffering_msg = Message :: new_buffering ( 42 )
2405+ . other_fields ( & [ ( "extra-field" , & true ) ] )
2406+ . build ( ) ;
2407+ match buffering_msg. view ( ) {
2408+ MessageView :: Buffering ( buffering_msg) => {
2409+ assert_eq ! ( buffering_msg. get_percent( ) , 42 ) ;
2410+ if let Some ( other_fields) = buffering_msg. get_structure ( ) {
2411+ assert ! ( other_fields. has_field( "extra-field" ) ) ;
2412+ }
2413+ }
2414+ _ => panic ! ( "buffering_msg.view() is not a MessageView::Buffering(_)" ) ,
2415+ }
23882416 }
23892417}
You can’t perform that action at this time.
0 commit comments