Skip to content

Commit d74b5ca

Browse files
committed
TEST: Add another try_append_row test
1 parent a72528b commit d74b5ca

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/append.rs

+18
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ fn append_row_existing() {
5353
Err(ShapeError::from_kind(ErrorKind::IncompatibleLayout)));
5454
}
5555

56+
#[test]
57+
fn append_row_col_len_1() {
58+
// Test appending 1 row and then cols from shape 1 x 1
59+
let mut a = Array::zeros((1, 1));
60+
a.try_append_row(aview1(&[1.])).unwrap(); // shape 2 x 1
61+
a.try_append_column(aview1(&[2., 3.])).unwrap(); // shape 2 x 2
62+
assert_eq!(a.try_append_row(aview1(&[1.])),
63+
Err(ShapeError::from_kind(ErrorKind::IncompatibleShape)));
64+
assert_eq!(a.try_append_row(aview1(&[1., 2.])),
65+
Err(ShapeError::from_kind(ErrorKind::IncompatibleLayout)));
66+
a.try_append_column(aview1(&[4., 5.])).unwrap(); // shape 2 x 3
67+
assert_eq!(a.shape(), &[2, 3]);
68+
69+
assert_eq!(a,
70+
array![[0., 2., 4.],
71+
[1., 3., 5.]]);
72+
}
73+
5674
#[test]
5775
fn append_column() {
5876
let mut a = Array::zeros((4, 0));

0 commit comments

Comments
 (0)