Commit 880154eb authored by Steffen Müthing's avatar Steffen Müthing

Merge branch 'feature/#2-testtypetree-child-access' into 'master'

testtypetree: Test (in)valid child() access

This is an addendum to @carsten.graeser's merge request !5: I originally
added a comment; now I've turned it into a proper test.

Please note that even though this merge request can be merged as-is, one
of the four new tests will only pass once !5 is merged.

See merge request !6
parents 1230fc40 685a5c5d
......@@ -6,6 +6,13 @@ exclude_from_headercheck(
dune_add_test(SOURCES testtypetree.cc
COMPILE_DEFINITIONS TEST_TYPETREE)
foreach(TEST_FAILURE 2 3 5 6)
dune_add_test(NAME testtypetree_fail${TEST_FAILURE}
SOURCES testtypetree.cc
COMPILE_DEFINITIONS TEST_TYPETREE;FAILURE${TEST_FAILURE}
EXPECT_COMPILE_FAIL)
endforeach()
dune_add_test(SOURCES testtypetreetransformation.cc
COMPILE_DEFINITIONS TEST_TYPETREE)
......
......@@ -156,6 +156,34 @@ int main(int argc, char** argv)
0>::result == TI::depth),
"Error in AccumulateValue");
// Test valid and invalid child access. Invalid access should be caught at compile time
auto const _0 = Dune::TypeTree::index_constant<0>();
auto const _1 = Dune::TypeTree::index_constant<1>();
auto const _2 = Dune::TypeTree::index_constant<2>();
auto const _3 = Dune::TypeTree::index_constant<3>();
// 1: valid access
auto x1 = child(sp1_1, _0);
#ifdef FAILURE2
// 2: invalid access (too few children)
auto x2 = child(sp1_1, _3);
#endif
#ifdef FAILURE3
// 3: invalid access (child has no children)
auto x3 = child(sp1_1, _0, _0);
#endif
// 4: valid access
auto x4 = child(sc1_1, _1, _2);
#ifdef FAILURE5
// 5: invalid access (too few children)
auto x5 = child(sc1_1, _3);
#endif
#ifdef FAILURE6
// 6: invalid access (child has no children)
auto x6 = child(sc1_1, _0, _0);
#endif
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment