bottest/tests/unit/basic/basic_keywords_validation_str_val.rs

27 lines
590 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_val_parsing() {
assert_eq!("123.45".trim().parse::<f64>().unwrap_or(0.0), 123.45);
assert_eq!(" 456 ".trim().parse::<f64>().unwrap_or(0.0), 456.0);
assert_eq!("abc".trim().parse::<f64>().unwrap_or(0.0), 0.0);
}
#[test]
2025-12-23 18:41:29 -03:00
fn test_cint_rounding() {
assert_eq!(2.4_f64.round() as i64, 2);
assert_eq!(2.5_f64.round() as i64, 3);
assert_eq!(2.6_f64.round() as i64, 3);
assert_eq!((-2.5_f64).round() as i64, -3);
}