From bcc468dc2decd48866c3b9e8ec72336b7ecb5ffa Mon Sep 17 00:00:00 2001 From: Chris Rogers <chris.rogers@stfc.ac.uk> Date: Thu, 19 Mar 2020 16:46:39 +0000 Subject: [PATCH] Add out of bounds test to NDGrid --- .../Fields/Interpolation/NDGridTest.cpp | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/classic_src/Fields/Interpolation/NDGridTest.cpp b/tests/classic_src/Fields/Interpolation/NDGridTest.cpp index 5f339086a..01e6ec41b 100644 --- a/tests/classic_src/Fields/Interpolation/NDGridTest.cpp +++ b/tests/classic_src/Fields/Interpolation/NDGridTest.cpp @@ -339,9 +339,26 @@ TEST_F(NDGridTest, DualTest) { } } -TEST_F(NDGridTest, IsOutOfBoundsTest) { +TEST_F(NDGridTest, IsOutOfBoundsBeginTest) { // nb isOutOfBounds is defined in Mesh.hh (but tested here for convenience - EXPECT_TRUE(false) << "Do the test" << std::endl; + interpolation::Mesh::Iterator it = grid_m->begin(); + EXPECT_FALSE(it.isOutOfBounds()); + for (size_t i = 0; i < it.getState().size(); ++i) { + it[i] -= 1; + EXPECT_TRUE(it.isOutOfBounds()); + it[i] += 1; + } +} + +TEST_F(NDGridTest, IsOutOfBoundsEndTest) { + interpolation::Mesh::Iterator it = grid_m->end(); + it--; + EXPECT_FALSE(it.isOutOfBounds()); + for (size_t i = 0; i < it.getState().size(); ++i) { + it[i] += 1; + EXPECT_TRUE(it.isOutOfBounds()); + it[i] -= 1; + } } } // namespace ndgridtest \ No newline at end of file -- GitLab