From 57541aa2533e2331505ad474b6d16ab07a7d543d Mon Sep 17 00:00:00 2001 From: Andreas Longva Date: Wed, 5 May 2021 09:42:31 +0200 Subject: [PATCH] Add tests to ensure macros compile for all built-in types --- nalgebra-macros/tests/tests.rs | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/nalgebra-macros/tests/tests.rs b/nalgebra-macros/tests/tests.rs index 88fbb9ae..206e5e66 100644 --- a/nalgebra-macros/tests/tests.rs +++ b/nalgebra-macros/tests/tests.rs @@ -143,3 +143,71 @@ fn dmatrix_trybuild_tests() { // Verify error message when we give a matrix with mismatched dimensions t.compile_fail("tests/trybuild/dmatrix_mismatched_dimensions.rs"); } + +#[test] +fn matrix_builtin_types() { + // Check that matrix! compiles for all built-in types + const _: SMatrix = matrix![0, 1; 2, 3]; + const _: SMatrix = matrix![0, 1; 2, 3]; + const _: SMatrix = matrix![0, 1; 2, 3]; + const _: SMatrix = matrix![0, 1; 2, 3]; + const _: SMatrix = matrix![0, 1; 2, 3]; + const _: SMatrix = matrix![0, 1; 2, 3]; + const _: SMatrix = matrix![0, 1; 2, 3]; + const _: SMatrix = matrix![0, 1; 2, 3]; + const _: SMatrix = matrix![0, 1; 2, 3]; + const _: SMatrix = matrix![0, 1; 2, 3]; + const _: SMatrix = matrix![0.0, 1.0; 2.0, 3.0]; + const _: SMatrix = matrix![0.0, 1.0; 2.0, 3.0]; +} + +#[test] +fn vector_builtin_types() { + // Check that vector! compiles for all built-in types + const _: SVector = vector![0, 1, 2, 3]; + const _: SVector = vector![0, 1, 2, 3]; + const _: SVector = vector![0, 1, 2, 3]; + const _: SVector = vector![0, 1, 2, 3]; + const _: SVector = vector![0, 1, 2, 3]; + const _: SVector = vector![0, 1, 2, 3]; + const _: SVector = vector![0, 1, 2, 3]; + const _: SVector = vector![0, 1, 2, 3]; + const _: SVector = vector![0, 1, 2, 3]; + const _: SVector = vector![0, 1, 2, 3]; + const _: SVector = vector![0.0, 1.0, 2.0, 3.0]; + const _: SVector = vector![0.0, 1.0, 2.0, 3.0]; +} + +#[test] +fn dmatrix_builtin_types() { + // Check that dmatrix! compiles for all built-in types + let _: DMatrix = dmatrix![0, 1; 2, 3]; + let _: DMatrix = dmatrix![0, 1; 2, 3]; + let _: DMatrix = dmatrix![0, 1; 2, 3]; + let _: DMatrix = dmatrix![0, 1; 2, 3]; + let _: DMatrix = dmatrix![0, 1; 2, 3]; + let _: DMatrix = dmatrix![0, 1; 2, 3]; + let _: DMatrix = dmatrix![0, 1; 2, 3]; + let _: DMatrix = dmatrix![0, 1; 2, 3]; + let _: DMatrix = dmatrix![0, 1; 2, 3]; + let _: DMatrix = dmatrix![0, 1; 2, 3]; + let _: DMatrix = dmatrix![0.0, 1.0; 2.0, 3.0]; + let _: DMatrix = dmatrix![0.0, 1.0; 2.0, 3.0]; +} + +#[test] +fn dvector_builtin_types() { + // Check that dvector! compiles for all built-in types + let _: DVector = dvector![0, 1, 2, 3]; + let _: DVector = dvector![0, 1, 2, 3]; + let _: DVector = dvector![0, 1, 2, 3]; + let _: DVector = dvector![0, 1, 2, 3]; + let _: DVector = dvector![0, 1, 2, 3]; + let _: DVector = dvector![0, 1, 2, 3]; + let _: DVector = dvector![0, 1, 2, 3]; + let _: DVector = dvector![0, 1, 2, 3]; + let _: DVector = dvector![0, 1, 2, 3]; + let _: DVector = dvector![0, 1, 2, 3]; + let _: DVector = dvector![0.0, 1.0, 2.0, 3.0]; + let _: DVector = dvector![0.0, 1.0, 2.0, 3.0]; +} \ No newline at end of file