Skip to content
Snippets Groups Projects
Commit bfbaaa89 authored by Tobias Leibner's avatar Tobias Leibner
Browse files

[test] fix tests in release mode

parent 72f039ec
No related branches found
No related tags found
1 merge request!41Fix compilation with icc, several other changes
......@@ -75,6 +75,8 @@ struct TestImp : public TestInterface<ImpTraits>
}
};
// If NDEBUG is defined, the CHECK_CRTP macro does nothing, so the code below will not throw
#ifndef NDEBUG
GTEST_TEST(crtp, fail)
{
TestInterface<FailTraits> test_iface;
......@@ -85,6 +87,7 @@ GTEST_TEST(crtp, fail)
},
Dune::XT::Common::Exceptions::CRTP_check_failed);
}
#endif // NDEBUG
GTEST_TEST(crtp, success)
{
......
......@@ -31,14 +31,15 @@ GTEST_TEST(dune_xt_common_field_matrix, creation_and_calculations)
ScalarMatrixType one(1.);
ScalarMatrixType one2{1.};
MatrixType mat({{0., 1., 2.}, {3., 4., 5.}});
// If NDEBUG is defined, the input is not checked in the constructor
#ifndef NDEBUG
EXPECT_ANY_THROW(MatrixType({{0., 2.}, {3., 4., 5.}}));
EXPECT_ANY_THROW(MatrixType({{0., 1., 2.}, {4., 5.}}));
EXPECT_ANY_THROW(MatrixType({{0., 2.}, {4., 5.}}));
EXPECT_ANY_THROW(ScalarMatrixType({{0., 2.}, {4., 5.}}));
#ifdef NDEBUG
EXPECT_ANY_THROW(MatrixType(rows + 1, cols - 1, 1.));
EXPECT_ANY_THROW(ScalarMatrixType(2, 3, 1.));
#endif
#endif // NDEBUG
EXPECT_EQ(zero[0][0], 0.);
EXPECT_EQ(one[0][0], 1.);
EXPECT_EQ(one2[0][0], 1.);
......
......@@ -34,7 +34,10 @@ GTEST_TEST(dune_xt_common_field_vector, creation_and_calculations)
VectorType test_vec{0, 1, 2, 3};
for (size_t ii = 0; ii < 4; ++ii)
EXPECT_EQ(test_vec[ii], ii);
// If NDEBUG is defined, the input is not checked in the constructor
#ifndef NDEBUG
EXPECT_ANY_THROW(VectorType({1, 2, 3}));
#endif
VectorType copy_assigned = test_vec;
check(copy_assigned, test_vec);
VectorType copy_constructed(test_vec);
......@@ -45,8 +48,11 @@ GTEST_TEST(dune_xt_common_field_vector, creation_and_calculations)
std::vector<double> std_vec2 = test_vec;
for (size_t ii = 0; ii < 4; ++ii)
EXPECT_EQ(std_vec2[ii], ii);
// If NDEBUG is defined, the input is not checked in the constructor
#ifndef NDEBUG
std_vec.resize(2);
EXPECT_ANY_THROW(VectorType{std_vec});
#endif
BaseVectorType base_vec{0, 1, 2, 3};
VectorType constructed_from_base(base_vec);
check(constructed_from_base, test_vec);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment