Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 810339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:52:06+00:00 2026-05-15T00:52:06+00:00

If I have user defined exceptions in my code, I can’t get Boost test

  • 0

If I have user defined exceptions in my code, I can’t get Boost test
to consider them as failures.

For example,

BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES(MyTest,1)
BOOST_AUTO_TEST_CASE(MyTest)
{
// code which throws user defined exception, not derived from std::exception.

}

I get a generic message:

Caught exception: ....
unknown location(0):....

It does not recognize this error as a failure since it is not a std::exception.
So it does not honor the expected_failures clause.

How do I enforce that the piece of code should always throw an exception?
THis seems to be a useful thing to want. In case future code changes cause the code
to pass and the exception is not thrown, I want to know that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T00:52:06+00:00Added an answer on May 15, 2026 at 12:52 am

    The EXPECTED_FAILURES are referring to failures against BOOST_REQUIRE or other assertions. The documentation clearly states:

    The feature is not intended to be used to check for expected functionality failures. To check that a particular input is causing an exception to be thrown use BOOST_CHECK_THROW family of testing tools.

    Emphasis was mine.

    The expected failures are meant to be used as a temporary workaround during testing when an assertion is failing but you want to temporarily ignore it.

    Taking a snippet from their expected failures spec:

    BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( my_test1, 1 )
    
    BOOST_AUTO_TEST_CASE( my_test1 )
    {
        BOOST_CHECK( 2 == 1 );
    }
    

    will result in output of

    test.cpp(10): error in "my_test1": check 2 == 1 failed
    
    Test suite "example" passed with:
      1 assertions out of 1 failed
      1 failures expected
      1 test case out of 1 passed
    

    As you can see, in spite of assertions failing, the test case still passed due to the use of expected failures.


    So if you need to verify that something is throwing an exception, you use code like the following:

    BOOST_AUTO_TEST_CASE(invalid_operation_should_throw_custom_exception)
    {
        MyObj obj;
        BOOST_REQUIRE_THROW(obj.invalid_operation(), CustomException);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you want them to be really equal (i.e. the… May 16, 2026 at 5:56 pm
  • Editorial Team
    Editorial Team added an answer Start with LINQ. It is a core concept in the… May 16, 2026 at 5:56 pm
  • Editorial Team
    Editorial Team added an answer It generally depends on how the remote site handles state… May 16, 2026 at 5:56 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

In PHP, I have created a user defined function. Example: <?php function test($one, $two)
I am passing user defined classes over sockets. The SendObject code is below. It
I have a user defined function in a SQL Server 2005 database which returns
I have a User table defined like this: CREATE TABLE Users( UserId int IDENTITY(1,1)
I have the following python code: try: pr.update() except ConfigurationException as e: returnString=e.line+' '+e.errormsg
Introduction I am aware that "user-defined conversions to or from a base class are
I have some original code that manages exception safety like this: void foo() {
I have my little client application which - when started - creates some user
I'm wondering what is the most elegant way to handle exceptions that depend on
I have a web service method where I would like to throw some custom

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.