46 lines
751 B
Rust
46 lines
751 B
Rust
#[test]
|
|
fn test_saturating_sub() {
|
|
let a: usize = 10;
|
|
dbg!(a.saturating_sub(5));
|
|
dbg!(a.saturating_sub(10));
|
|
dbg!(a.saturating_sub(15));
|
|
}
|
|
|
|
#[test]
|
|
fn test_remainder() {
|
|
dbg!(-6 % 5);
|
|
dbg!(6 % 5);
|
|
dbg!(6.3 % 5.0);
|
|
}
|
|
|
|
#[test]
|
|
fn test_ceil() {
|
|
dbg!(0.1_f32.ceil());
|
|
dbg!(-0.1_f32.ceil());
|
|
dbg!(5.9_f32.ceil());
|
|
dbg!(-5.9_f32.ceil());
|
|
}
|
|
|
|
#[test]
|
|
fn test_floor() {
|
|
dbg!(0.1_f32.floor());
|
|
dbg!((-0.1_f32).floor());
|
|
dbg!((-0.2_f32).floor());
|
|
dbg!((-0.3_f32).floor());
|
|
dbg!((-1.0_f32 / 5.0_f32).floor());
|
|
dbg!(5.9_f32.floor());
|
|
dbg!(-5.9_f32.floor());
|
|
}
|
|
|
|
#[test]
|
|
fn test_zero() {
|
|
dbg!(-0.0_f32 == 0.0_f32);
|
|
}
|
|
|
|
#[test]
|
|
fn test_ranges() {
|
|
for x in 0..5 {
|
|
dbg!(x);
|
|
}
|
|
}
|