bottest/tests/unit/basic/basic_keywords_math_basic_math.rs

62 lines
911 B
Rust
Raw Normal View History

2025-12-23 18:41:29 -03:00
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]
#[test]
2025-12-23 18:41:29 -03:00
fn test_int() {
assert_eq!(3.9_f64.trunc() as i64, 3);
assert_eq!((-3.9_f64).trunc() as i64, -3);
}
#[test]
2025-12-23 18:41:29 -03:00
fn test_floor_ceil() {
assert_eq!(3.7_f64.floor() as i64, 3);
assert_eq!(3.2_f64.ceil() as i64, 4);
}
#[test]
2025-12-23 18:41:29 -03:00
fn test_minmax() {
assert_eq!(10_i64.max(5), 10);
assert_eq!(10_i64.min(5), 5);
}
#[test]
2025-12-23 18:41:29 -03:00
fn test_mod() {
assert_eq!(17 % 5, 2);
}
#[test]
2025-12-23 18:41:29 -03:00
fn test_sgn() {
assert_eq!((-5_i64).signum(), -1);
assert_eq!(5_i64.signum(), 1);
assert_eq!(0_i64.signum(), 0);
}
#[test]
2025-12-23 18:41:29 -03:00
fn test_sqrt() {
assert!((16_f64.sqrt() - 4.0).abs() < 0.0001);
}
#[test]
2025-12-23 18:41:29 -03:00
fn test_pow() {
assert!((2_f64.powf(8.0) - 256.0).abs() < 0.0001);
}