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

Can we print a message _and_ exit with fatal? #583

Closed
alexpanter opened this issue Aug 31, 2023 · 1 comment
Closed

Can we print a message _and_ exit with fatal? #583

alexpanter opened this issue Aug 31, 2023 · 1 comment

Comments

@alexpanter
Copy link

alexpanter commented Aug 31, 2023

Problem description

Given a test that if fails should abort all further testing. This is attained with >> fatal:

bool test_create_camera() { ... }

"camera_tests"_test = []{
    expect(test_create_camera()) >> fatal) << "Camera was nullptr!";
    // more tests here...
};

If I cannot create a camera, all the next tests should be skipped. And I would also like to get the message "Camera was nullptr!" printed. However, I experience that >> fatal simply aborts the program without printing my message.

Instead, I can use this bit of code to do what I want - but it seems more complicated than should be necessary, and it doesn't allow me to forward arbitrary strings to std::cout:

expect(eq(test_create_camera(), "Camera was nullptr!"_b) >> fatal);

Specifications

  • Version: BOOST_UT_VERSION 1'1'9
  • Platform: Ubuntu 23.04
  • Compiler: g++ 12.3.0
@mordante
Copy link
Contributor

mordante commented Sep 6, 2023

I had the same issue and this feature has been added in #574. Please look at the documentation since the syntax is slightly different.

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