@@ -144,9 +144,9 @@ pub type LossPattern = Vec<f64>;
144144/// The meaning of the duplicate_pattern sequence is:
145145///
146146/// - The probability on index 0 describes how likely a packet will be duplicated
147- /// **if the previous packet was transmitted normally**.
147+ /// **if the previous packet was transmitted normally**.
148148/// - The probability on index 1 describes how likely a packet will be duplicated
149- /// **if the previous packet was duplicated**.
149+ /// **if the previous packet was duplicated**.
150150/// - ...
151151///
152152/// For example, if the duplicate_pattern is [0.8, 0.1], and packet 100 is not duplicated, then the
@@ -216,6 +216,8 @@ pub trait DuplicateTrace: Send {
216216
217217#[ cfg( test) ]
218218mod test {
219+ use model:: TraceBwConfig ;
220+
219221 use self :: model:: bw:: Forever ;
220222
221223 use super :: * ;
@@ -346,6 +348,48 @@ mod test {
346348 ) ;
347349 }
348350
351+ #[ test]
352+ fn test_trace_bw ( ) {
353+ let mut trace_bw = TraceBwConfig :: new ( )
354+ . pattern ( vec ! [
355+ (
356+ Duration :: from_millis( 1 ) ,
357+ vec![
358+ Bandwidth :: from_kbps( 29123 ) ,
359+ Bandwidth :: from_kbps( 41242 ) ,
360+ Bandwidth :: from_kbps( 7395 ) ,
361+ ] ,
362+ ) ,
363+ (
364+ Duration :: from_millis( 2 ) ,
365+ vec![ Bandwidth :: from_mbps( 1 ) , Bandwidth :: from_kbps( 8542 ) ] ,
366+ ) ,
367+ ] )
368+ . build ( ) ;
369+
370+ assert_eq ! (
371+ trace_bw. next_bw( ) ,
372+ Some ( ( Bandwidth :: from_bps( 29123000 ) , Duration :: from_millis( 1 ) ) )
373+ ) ;
374+ assert_eq ! (
375+ trace_bw. next_bw( ) ,
376+ Some ( ( Bandwidth :: from_bps( 41242000 ) , Duration :: from_millis( 1 ) ) )
377+ ) ;
378+ assert_eq ! (
379+ trace_bw. next_bw( ) ,
380+ Some ( ( Bandwidth :: from_bps( 7395000 ) , Duration :: from_millis( 1 ) ) )
381+ ) ;
382+ assert_eq ! (
383+ trace_bw. next_bw( ) ,
384+ Some ( ( Bandwidth :: from_bps( 1000000 ) , Duration :: from_millis( 2 ) ) )
385+ ) ;
386+ assert_eq ! (
387+ trace_bw. next_bw( ) ,
388+ Some ( ( Bandwidth :: from_bps( 8542000 ) , Duration :: from_millis( 2 ) ) )
389+ ) ;
390+ assert_eq ! ( trace_bw. next_bw( ) , None ) ;
391+ }
392+
349393 #[ test]
350394 #[ cfg( feature = "serde" ) ]
351395 fn test_model_serde ( ) {
0 commit comments