From 6df81c2292ee105c8ccfcaca2fdea4232512ccaa Mon Sep 17 00:00:00 2001 From: Owen Brooks Date: Fri, 17 Jun 2022 18:23:59 +1000 Subject: [PATCH] Add test for formatting of empty matrix --- tests/core/matrix.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/core/matrix.rs b/tests/core/matrix.rs index 5aec8302..c1278e7e 100644 --- a/tests/core/matrix.rs +++ b/tests/core/matrix.rs @@ -80,7 +80,7 @@ fn iter() { #[test] fn debug_output_semicolon_delimited_rowwise() { let m = Matrix2::new(1.0, 2.0, 3.0, 4.0); - let expected_output = "[1.0, 2.0; 3.0, 4.0]"; // Current output on the nightly channel. + let expected_output = "[1.0, 2.0; 3.0, 4.0]"; let current_output = format!("{:?}", m); dbg!(expected_output); dbg!(¤t_output); @@ -88,6 +88,18 @@ fn debug_output_semicolon_delimited_rowwise() { assert!(current_output == expected_output); } +#[test] +fn format_empty_matrix() { + let empty_row: [f32; 0] = []; + let m = na::DMatrix::from_row_slice(0, 0, &empty_row); + let expected_output = "[ ]"; + let current_output = format!("{}", m); + dbg!(expected_output); + dbg!(¤t_output); + + assert!(current_output == expected_output); +} + #[test] fn is_column_major() { let a = Matrix2x3::new(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);