Skip to content

Parameterized tests require creating (unused) instances of the tested types. #539

@cschreib

Description

@cschreib

Expected Behavior

#include <boost/ut.hpp>
#include <array>
#include <tuple>

using namespace boost::ut;

struct my_expensive_type {
  std::array<int, 1'000'000> data;
};

int main() {
  "test"_test = []<typename T>() { expect(that % sizeof(T) > 0); } |
                std::tuple<my_expensive_type>{};
}

This should compile and run, perhaps with a change to the API (i.e., not instantiate tuple).

Actual Behavior

This compiles, but generates a segfault at runtime (stack exhausted).

Steps to Reproduce the Problem

  1. Compile and run the test above.

Specifications

  • Version: 1.1.9
  • Platform: Linux x86_64
  • Subsystem: g++ v10.3.0

Extra information

The example above is contrived, but the issue is real. This test should not create any instance of the tested type, since no instance is actually used. Actual instances may be created inside the test body, but this should be left up to the user to decide. Here the type cannot be created on the stack, hence cannot be used in parameterized tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions