Add trybuild tests to test error message reported when matrix dims mismatch
This commit is contained in:
parent
07d41e457b
commit
da077497a2
|
@ -17,3 +17,4 @@ proc-macro2 = "1.0"
|
|||
|
||||
[dev-dependencies]
|
||||
nalgebra = { version = "0.26.1", path = ".." }
|
||||
trybuild = "1.0.42"
|
||||
|
|
|
@ -115,3 +115,19 @@ fn dvector_small_dims_exhaustive() {
|
|||
assert_eq_and_type!(dvector![1, 2, 3, 4, 5], DVector::from_column_slice(&[1, 2, 3, 4, 5]));
|
||||
assert_eq_and_type!(dvector![1, 2, 3, 4, 5, 6], DVector::from_column_slice(&[1, 2, 3, 4, 5, 6]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn matrix_trybuild_tests() {
|
||||
let t = trybuild::TestCases::new();
|
||||
|
||||
// Verify error message when we give a matrix with mismatched dimensions
|
||||
t.compile_fail("tests/trybuild/matrix_mismatched_dimensions.rs");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dmatrix_trybuild_tests() {
|
||||
let t = trybuild::TestCases::new();
|
||||
|
||||
// Verify error message when we give a matrix with mismatched dimensions
|
||||
t.compile_fail("tests/trybuild/dmatrix_mismatched_dimensions.rs");
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
use nalgebra_macros::dmatrix;
|
||||
|
||||
fn main() {
|
||||
dmatrix![1, 2, 3;
|
||||
4, 5];
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
error: Unexpected number of entries in row 1. Expected 3, found 2 entries.
|
||||
--> $DIR/dmatrix_mismatched_dimensions.rs:5:13
|
||||
|
|
||||
5 | 4, 5];
|
||||
| ^
|
|
@ -0,0 +1,6 @@
|
|||
use nalgebra_macros::matrix;
|
||||
|
||||
fn main() {
|
||||
matrix![1, 2, 3;
|
||||
4, 5];
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
error: Unexpected number of entries in row 1. Expected 3, found 2 entries.
|
||||
--> $DIR/matrix_mismatched_dimensions.rs:5:13
|
||||
|
|
||||
5 | 4, 5];
|
||||
| ^
|
Loading…
Reference in New Issue