TEST_CASE("Section in a Loop", "[section][loop]") {
for (int x = 0; x < 11; ++x) {
SECTION("dave", "") {
const int y(11);
REQUIRE(x < y);
}
}
}clang++ -I../Catch/include --std=c++98 NamedSections.t.cpp -o NamedSections.bin && ./NamedSections.bin "Section in a loop"
All tests passed (1 assertion in 1 test case)
}
So Catch found the test case by name and executed it. Once the section "dave" had been entered once, it wasn't entered again.TEST_CASE("Section testing values", "[section][loop]") {
const int allowedValues[] = { 1, 2, 3 };
const size_t allowedValuesSize(sizeof(allowedValues)/sizeof(allowedValues[0]));
for (int x = 0; x < allowedValuesSize; ++x) {
SECTION("allowedValues", "") {
const int y(allowedValues[x]);
REQUIRE(y < 4);
}
}
}
clang++ -I../Catch/include --std=c++98 NamedSections.t.cpp -o NamedSections.bin && ./NamedSections.bin "Section testing values"
All tests passed (1 assertion in 1 test case)
TEST_CASE("Named Section in a Loop", "[namedsection][loop]") {
for (int x = 0; x < 11; ++x) {
std::ostringstream ss;
ss << "section2." << x;
SECTION(ss.str(), "") {
const int y(11);
REQUIRE(x < y);
}
}
}
clang++ -I../Catch/include --std=c++98 NamedSections.t.cpp -o NamedSections.bin && ./NamedSections.bin "Named section in a loop"
All tests passed (11 assertions in 1 test case)