Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
tests
  • Loading branch information
PaulXiCao committed Oct 25, 2025
commit 648072c4b03c8c1563a6b39ecda7aa2e2040c013
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,25 @@ pub(crate) mod test {
pub const _nan_neg1i: Complex64 = Complex::new(f64::NAN, -1.0);
pub const _nan_nani: Complex64 = Complex::new(f64::NAN, f64::NAN);

#[test]
fn test_from_real() {
for re in [
-3.123,
-1.0,
0.0,
1.0,
5.67,
f64::INFINITY,
f64::NEG_INFINITY,
] {
assert_eq!(Complex::new(re, 0.0), Complex::from_real(re));
}
{
let x = Complex::from_real(f64::NAN);
assert!(x.re.is_nan() && x.im.is_zero());
}
}

#[test]
fn test_consts() {
// check our constants are what Complex::new creates
Expand Down