Skip to content

Commit 09e90e2

Browse files
author
Daniel
committed
test_scalar now used DoubleNear and checks directly within loop computing convergence rates
1 parent 9e31826 commit 09e90e2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tests/examples/scalar/test_scalar.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ MATCHER (DoubleMore, "")
1515
return get<0>(arg) > get<1>(arg);
1616
}
1717

18+
1819
/*
1920
* For Lobatto nodes, the resulting method should of order 2*M-2 with M=number of nodes
2021
* The test below verifies that the code approximately (up to a safety factor) reproduces
@@ -30,7 +31,6 @@ TEST(ConvergenceTest, ScalarSDC)
3031

3132
vector<double> err(nsteps.size());
3233
vector<double> convrate(nsteps.size()-1);
33-
vector<double> expected_cr(nsteps.size()-1);
3434

3535
double dt;
3636

@@ -52,15 +52,14 @@ TEST(ConvergenceTest, ScalarSDC)
5252
for ( size_t i = 0; i<=nsteps_l-2; ++i)
5353
{
5454
convrate[i] = log10(err[i+1]/err[i])/log10(double(nsteps[i])/double(nsteps[i+1]));
55-
// The expected convergence rate for Lobatto nodes is 2*nnodes-2, but because
56-
// it will typically be not matched exactly, put in a security factor
57-
expected_cr[i] = 0.9*double(2*nnodes-2);
55+
56+
EXPECT_THAT(convrate[i], testing::DoubleNear(double(2*nnodes-2), 0.99)) << "Convergence rate at node " << i << " not within expected range";
5857
}
5958

6059
// NOTE: There is probably a much more elegant way to test this, because
6160
// expected_cr contains the same value in all entries. But I could not so far figure
6261
// out how to build a more clever MATCHER here so far....
63-
EXPECT_THAT(convrate, testing::Pointwise(DoubleMore(), expected_cr ));
62+
// EXPECT_THAT(convrate, testing::Pointwise(DoubleMore(), expected_cr ));
6463

6564
}
6665
}

0 commit comments

Comments
 (0)