Refactor abomonation test suite using macro
This commit is contained in:
parent
f67a7bd324
commit
916006f80a
|
@ -6,29 +6,25 @@ use rand::random;
|
||||||
use abomonation::{Abomonation, encode, decode};
|
use abomonation::{Abomonation, encode, decode};
|
||||||
use nalgebra::{DMatrix, Matrix3x4, Point3, Translation3, Rotation3};
|
use nalgebra::{DMatrix, Matrix3x4, Point3, Translation3, Rotation3};
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn abomonate_matrix3x4() {
|
|
||||||
assert_encode_and_decode(&random::<Matrix3x4<f32>>());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn abomonate_point3() {
|
|
||||||
assert_encode_and_decode(&random::<Point3<f64>>());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn abomonate_dmatrix() {
|
fn abomonate_dmatrix() {
|
||||||
assert_encode_and_decode(&DMatrix::<f32>::new_random(3, 5));
|
assert_encode_and_decode(&DMatrix::<f32>::new_random(3, 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
macro_rules! test_abomonation(
|
||||||
fn abomonate_translation3() {
|
($($test: ident, $ty: ty);* $(;)*) => {$(
|
||||||
assert_encode_and_decode(&random::<Translation3<f32>>());
|
#[test]
|
||||||
}
|
fn $test() {
|
||||||
|
assert_encode_and_decode(&random::<$ty>());
|
||||||
|
}
|
||||||
|
)*}
|
||||||
|
);
|
||||||
|
|
||||||
#[test]
|
test_abomonation! {
|
||||||
fn abomonate_rotation3() {
|
abomonate_matrix3x4, Matrix3x4<f32>;
|
||||||
assert_encode_and_decode(&random::<Rotation3<f64>>());
|
abomonate_point3, Point3<f32>;
|
||||||
|
abomonate_translation3, Translation3<f64>;
|
||||||
|
abomonate_rotation3, Rotation3<f64>;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assert_encode_and_decode<T: Abomonation + PartialEq>(data: &T) {
|
fn assert_encode_and_decode<T: Abomonation + PartialEq>(data: &T) {
|
||||||
|
|
Loading…
Reference in New Issue