Fixed bug in unit test causing crashes, altered corner case test for column insertion

release/4.3a0
Alex Cunningham 2010-02-24 18:09:15 +00:00
parent 022f706d94
commit f8c4e1fe27
2 changed files with 18 additions and 9 deletions

View File

@ -691,7 +691,7 @@ TEST( GaussianFactorGraph, elimination )
GaussianFactorGraph fg; GaussianFactorGraph fg;
Matrix Ap = eye(1), An = eye(1) * -1; Matrix Ap = eye(1), An = eye(1) * -1;
Vector b = Vector_(1, 0.0); Vector b = Vector_(1, 0.0);
SharedDiagonal sigma = sharedSigma(2,2.0); SharedDiagonal sigma = sharedSigma(1,2.0);
fg.add("x1", An, "x2", Ap, b, sigma); fg.add("x1", An, "x2", Ap, b, sigma);
fg.add("x1", Ap, b, sigma); fg.add("x1", Ap, b, sigma);
fg.add("x2", Ap, b, sigma); fg.add("x2", Ap, b, sigma);

View File

@ -170,9 +170,12 @@ TEST( matrix, insert_column )
insertColumn(big, col, j); insertColumn(big, col, j);
Matrix expected = Matrix_(5, 6, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, Matrix expected = Matrix_(5, 6,
0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0); 0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0, 0.0, 0.0);
CHECK(assert_equal(expected, big)); CHECK(assert_equal(expected, big));
} }
@ -181,15 +184,21 @@ TEST( matrix, insert_column )
TEST( matrix, insert_subcolumn ) TEST( matrix, insert_subcolumn )
{ {
Matrix big = zeros(5, 6); Matrix big = zeros(5, 6);
Vector col = ones(2); Vector col1 = ones(2);
size_t i = 1; size_t i = 1;
size_t j = 3; size_t j = 3;
insertColumn(big, col, i, j); insertColumn(big, col1, i, j); // check 1
Matrix expected = Matrix_(5, 6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Vector col2 = ones(1);
0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, insertColumn(big, col2, 4, 5); // check 2
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
Matrix expected = Matrix_(5, 6,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 1.0);
CHECK(assert_equal(expected, big)); CHECK(assert_equal(expected, big));
} }