complex: update testing imports and hash
This commit is contained in:
parent
e672d006a4
commit
8cb026e273
|
@ -13,6 +13,8 @@
|
||||||
extern crate num_traits as traits;
|
extern crate num_traits as traits;
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
#[cfg(test)]
|
||||||
|
use std::hash;
|
||||||
use std::ops::{Add, Div, Mul, Neg, Sub};
|
use std::ops::{Add, Div, Mul, Neg, Sub};
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
|
@ -594,6 +596,14 @@ impl<T> serde::Deserialize for Complex<T> where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
fn hash<T: hash::Hash>(x: &T) -> u64 {
|
||||||
|
use std::hash::Hasher;
|
||||||
|
let mut hasher = hash::SipHasher::new();
|
||||||
|
x.hash(&mut hasher);
|
||||||
|
hasher.finish()
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
#![allow(non_upper_case_globals)]
|
#![allow(non_upper_case_globals)]
|
||||||
|
@ -601,7 +611,7 @@ mod test {
|
||||||
use super::{Complex64, Complex};
|
use super::{Complex64, Complex};
|
||||||
use std::f64;
|
use std::f64;
|
||||||
|
|
||||||
use {Zero, One, Float};
|
use traits::{Zero, One, Float};
|
||||||
|
|
||||||
pub const _0_0i : Complex64 = Complex { re: 0.0, im: 0.0 };
|
pub const _0_0i : Complex64 = Complex { re: 0.0, im: 0.0 };
|
||||||
pub const _1_0i : Complex64 = Complex { re: 1.0, im: 0.0 };
|
pub const _1_0i : Complex64 = Complex { re: 1.0, im: 0.0 };
|
||||||
|
@ -994,7 +1004,7 @@ mod test {
|
||||||
|
|
||||||
mod complex_arithmetic {
|
mod complex_arithmetic {
|
||||||
use super::{_0_0i, _1_0i, _1_1i, _0_1i, _neg1_1i, _05_05i, all_consts};
|
use super::{_0_0i, _1_0i, _1_1i, _0_1i, _neg1_1i, _05_05i, all_consts};
|
||||||
use Zero;
|
use traits::Zero;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_add() {
|
fn test_add() {
|
||||||
|
|
Loading…
Reference in New Issue