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

Strange output #662

Open
robert-andrzejuk opened this issue Feb 9, 2025 · 1 comment
Open

Strange output #662

robert-andrzejuk opened this issue Feb 9, 2025 · 1 comment

Comments

@robert-andrzejuk
Copy link

The below code generates strange output.
Multiple times the Failed tests are listed in an incremental manner.
I would expect each check to be listed once.

Code:

#define BOOST_UT_DISABLE_MODULE
#include "ut.hpp"

#define EXPECT_THAT(expr) expect(that % expr) << "\"" #expr "\"\n"

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

    "basic"_test = [] {
        int a1 = 1, a2 = 1, a3 = 1, a4 = 1, a5 = 1, a6 = 1;
        int b1 = 0, b2 = 0, b3 = 0, b4 = 0, b5 = 0, b6 = 0;

        EXPECT_THAT(a1 == b1);
        EXPECT_THAT(a2 == b2);
        EXPECT_THAT(a3 == b3);
        EXPECT_THAT(a4 == b4) << fatal;
        EXPECT_THAT(a5 == b5);
        EXPECT_THAT(a6 == b6);
    };
}

Output:

Running test "basic"... FAILED
in: C:\Github\beman\scope\tests\beman\scope\scope.test.cpp:17 - test condition:  [1 == 0]

 "a1 == b1"

Running test "basic"... FAILED
in: C:\Github\beman\scope\tests\beman\scope\scope.test.cpp:17 - test condition:  [1 == 0] "a1 == b1"
FAILED
in: C:\Github\beman\scope\tests\beman\scope\scope.test.cpp:18 - test condition:  [1 == 0]

 "a2 == b2"

Running test "basic"... FAILED
in: C:\Github\beman\scope\tests\beman\scope\scope.test.cpp:17 - test condition:  [1 == 0] "a1 == b1"
FAILED
in: C:\Github\beman\scope\tests\beman\scope\scope.test.cpp:18 - test condition:  [1 == 0] "a2 == b2"
FAILED
in: C:\Github\beman\scope\tests\beman\scope\scope.test.cpp:19 - test condition:  [1 == 0]

 "a3 == b3"

Running test "basic"... FAILED
in: C:\Github\beman\scope\tests\beman\scope\scope.test.cpp:17 - test condition:  [1 == 0] "a1 == b1"
FAILED
in: C:\Github\beman\scope\tests\beman\scope\scope.test.cpp:18 - test condition:  [1 == 0] "a2 == b2"
FAILED
in: C:\Github\beman\scope\tests\beman\scope\scope.test.cpp:19 - test condition:  [1 == 0] "a3 == b3"
FAILED
in: C:\Github\beman\scope\tests\beman\scope\scope.test.cpp:20 - test condition:  [1 == 0]

 "a4 == b4"

===============================================================================
Suite global
tests:   1 | 5 failed
asserts: 5 | 0 passed | 5 failed
@JeffGarland
Copy link

I'm not sure what the interaction issue is here but maybe that it's == instead of % you'd need in the macro -- regardless you should be able to write this without the macro and get decent location information anyway.

    expect(a1 == b1);
    expect(fatal(a4 == b4)) << "fatal errror a4 not equal b4";

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