@@ -413,20 +413,60 @@ mod tests {
413
413
}
414
414
}
415
415
416
- // NOTE: use for new test in future: // / Full PID operation with mixed signed integer checking to make sure they're equal
416
+ /// Full PID operation with mixed signed integer checking to make sure they're equal
417
417
/// PID operation with zero'd values, checking to see if different floats equal each other
418
418
#[ test]
419
- fn signed_integers_zeros ( ) {
419
+ fn signed_integers ( ) {
420
420
let mut pid_i8 = Pid :: new ( 10i8 , 100 ) ;
421
421
pid_i8. p ( 0 , 100 ) . i ( 0 , 100 ) . d ( 0 , 100 ) ;
422
422
423
+ let mut pid_i16 = Pid :: new ( 10i16 , 100i16 ) ;
424
+ pid_i16. p ( 0i16 , 100i16 ) . i ( 0i16 , 100i16 ) . d ( 0i16 , 100i16 ) ;
425
+
423
426
let mut pid_i32 = Pid :: new ( 10i32 , 100 ) ;
424
427
pid_i32. p ( 0 , 100 ) . i ( 0 , 100 ) . d ( 0 , 100 ) ;
425
428
429
+ let mut pid_i64 = Pid :: new ( 10i64 , 100 ) ;
430
+ pid_i64. p ( 0 , 100 ) . i ( 0 , 100 ) . d ( 0 , 100 ) ;
431
+
432
+ let mut pid_i128 = Pid :: new ( 10i128 , 100 ) ;
433
+ pid_i128. p ( 0 , 100 ) . i ( 0 , 100 ) . d ( 0 , 100 ) ;
434
+
435
+ for _ in 0 ..5 {
436
+ assert_eq ! (
437
+ pid_i8. next_control_output( 0i8 ) . output as i16 ,
438
+ pid_i16. next_control_output( 0i16 ) . output,
439
+ ) ;
440
+
441
+ assert_eq ! (
442
+ pid_i16. next_control_output( 0i16 ) . output as i32 ,
443
+ pid_i32. next_control_output( 0i32 ) . output,
444
+ ) ;
445
+
446
+ assert_eq ! (
447
+ pid_i32. next_control_output( 0i32 ) . output as i64 ,
448
+ pid_i64. next_control_output( 0i64 ) . output
449
+ ) ;
450
+
451
+ assert_eq ! (
452
+ pid_i64. next_control_output( 0i64 ) . output as i128 ,
453
+ pid_i128. next_control_output( 0i128 ) . output
454
+ ) ;
455
+ }
456
+ }
457
+
458
+ #[ test]
459
+ fn float_match_integers ( ) {
460
+ let mut pid_i32 = Pid :: new ( 10i32 , 100 ) ;
461
+ pid_i32. p ( 0 , 100 ) . i ( 0 , 100 ) . d ( 0 , 100 ) ;
462
+
463
+ let mut pid_f32 = Pid :: new ( 10.0f32 , 100.0 ) ;
464
+ pid_f32. p ( 0.0 , 100.0 ) . i ( 0.0 , 100.0 ) . d ( 0.0 , 100.0 ) ;
465
+
426
466
for _ in 0 ..5 {
427
467
assert_eq ! (
428
- pid_i32. next_control_output( 0 ) . output,
429
- pid_i8 . next_control_output( 0i8 ) . output as i32
468
+ pid_i32. next_control_output( 0i32 ) . output as f32 ,
469
+ pid_f32 . next_control_output( 0f32 ) . output
430
470
) ;
431
471
}
432
472
}
0 commit comments