Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number of asserts is reported wrongly #624

Open
SimonMarynissen opened this issue Apr 25, 2024 · 1 comment
Open

Number of asserts is reported wrongly #624

SimonMarynissen opened this issue Apr 25, 2024 · 1 comment

Comments

@SimonMarynissen
Copy link

For the following very simple code:

#include <boost/ut.hpp>
#include <vector>

int main() {
  using namespace boost::ut;

  "args"_test = [](const auto& arg) {
    expect(arg > 0_i) << "all values greater than 0";
  } | std::vector{1, 2, 3};
}

Expected Behavior

It outputs Suite 'global': all tests passed (6 asserts in 3 tests)

Actual Behavior

It should output Suite 'global': all tests passed (3 asserts in 3 tests)

It is not always just double the number of asserts. For example on my own code I got Suite 'global': all tests passed (1806 asserts in 84 tests), while each test has a single expect.

Steps to Reproduce the Problem

Check out on compiler explorer.

Specifications

  • Version: latest (2.0.1)
  • Platform: I tested both on msvc and gcc (I suspect clang too)
@DNKpp
Copy link

DNKpp commented Jul 5, 2024

From a quick view, I would guess that it somehow sums up the previous assertions twice + the current assertion.
To be more precise, I populated the test vector with different elements:

Elements Reported Assertions Reported tests
1 1 1
1, 3 3 2
1, 3, 4 6 3
1, 3, 4, 5 10 4

So it seems it sums up the partial sum of processed assertions (1 + 2 + 3 + 4 for the last case; like a gauss summation) instead of the actual number of assertions. You get the point.
Adding more assertions multiplies the number of assertions.

But that doesn't hold with your observation of getting 1806 assertions in 84 test...

EDIT: Have a look here. It's getting clearer when the expectation fails: https://godbolt.org/z/njea4c9sx
The output actually shows duplicated assertions (and warns about them).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants