From 916006f80a078732678d4568908cdd7cbe7b02c9 Mon Sep 17 00:00:00 2001 From: Eduard Bopp Date: Mon, 14 Aug 2017 12:46:25 +0200 Subject: [PATCH] Refactor abomonation test suite using macro --- tests/abomonation.rs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/tests/abomonation.rs b/tests/abomonation.rs index 8861342b..371a52b6 100644 --- a/tests/abomonation.rs +++ b/tests/abomonation.rs @@ -6,29 +6,25 @@ use rand::random; use abomonation::{Abomonation, encode, decode}; use nalgebra::{DMatrix, Matrix3x4, Point3, Translation3, Rotation3}; -#[test] -fn abomonate_matrix3x4() { - assert_encode_and_decode(&random::>()); -} - -#[test] -fn abomonate_point3() { - assert_encode_and_decode(&random::>()); -} - #[test] fn abomonate_dmatrix() { assert_encode_and_decode(&DMatrix::::new_random(3, 5)); } -#[test] -fn abomonate_translation3() { - assert_encode_and_decode(&random::>()); -} +macro_rules! test_abomonation( + ($($test: ident, $ty: ty);* $(;)*) => {$( + #[test] + fn $test() { + assert_encode_and_decode(&random::<$ty>()); + } + )*} +); -#[test] -fn abomonate_rotation3() { - assert_encode_and_decode(&random::>()); +test_abomonation! { + abomonate_matrix3x4, Matrix3x4; + abomonate_point3, Point3; + abomonate_translation3, Translation3; + abomonate_rotation3, Rotation3; } fn assert_encode_and_decode(data: &T) {