0

I have some code:

#include <catch2/catch_test_macros.hpp>

#include <iostream>

TEST_CASE("Section showcase") {
    {
        SECTION("A1") {
            std::cout << "A1 ";
        }   
        SECTION("A2") {
            std::cout << "A2 ";
        }
    }

    std::cout << "some intermedite code";

    {
        SECTION("B") {
            std::cout << "B1";
        }    
        SECTION("B1") {
            std::cout << "B2";
        }
    }
    std::cout << '\n';
}

Godbolt

I would like to get all combinations of these two blocks:

A1 some intermedite code B1
A1 some intermedite code B2
A2 some intermedite code B1
A2 some intermedite code B2

But catch2 seems just to go through the individual sections:

A1 some intermedite code
A2 some intermedite code
some intermedite code B1
some intermedite code B2

How can I create a "cartesian product" of two section groups?

Stein
  • 3,179
  • 5
  • 27
  • 51
  • 1
    I found a hacky way: Make the cart-product: `bool a1 = GENERATE(true, false); bool b1 = GENERATE(true, false)` and then use normal it-statements later – Stein Jun 29 '23 at 15:58
  • https://godbolt.org/z/cjb5sP57P – Marek R Jun 29 '23 at 17:01

0 Answers0