#46 Improved itassertion functionality

Next_Release
closed
None
4
2012-09-15
2006-10-03
No

I have made improvements to the functionality of the
it assertion macros. With these modifications it is
possible to write

it_assert1(1 > 0, "We can now use a normal" <<
" cout" << " string as message. Number " << 5 <<
std::endl);

I find this very useful to give more meaningful error
messages. Please consider incorporating this into
next release of it++. I am providing the modified
files as well as a patch file (compared to release
3.10.5). The modifications should be backwards
compatible and easy to apply.

Best regards,

George

Discussion

  • George Jöngren

    George Jöngren - 2006-10-03

    modified it assertion files

     
  • Adam Piątyszek

    Adam Piątyszek - 2006-10-03

    Logged In: YES
    user_id=1004597

    Hi George,

    Thanks for your interesting patch... I will try to discuss
    your request with other devs. If there are no objections, I
    will include this into our sources, however into the
    development branch (trunk), not the stable 3.10.x series.

    BR,
    /ediap

     
  • Adam Piątyszek

    Adam Piątyszek - 2006-10-06

    Logged In: YES
    user_id=1004597

    Hi George,

    Seems, that there are no objections to include your patch in
    the development branch of IT++. However, before I will do
    this, I have one question about your itassert.patch...
    Here is the it_assert_base macro you defined:

    define it_assert_base(t,s) \

    if(true) { \ if(!(t)) { \ std::ostringstream m_sout; \ m_sout << s; \

    itpp::it_assert_f(#t,m_sout.str().c_str(),FILE,LINE); \ } \ } \ else \ void(0)

    I wonder, what is the reason of this if (true) ... else
    statement? Could you comment on this?

    Thanks!
    BR,
    /ediap

     
  • Adam Piątyszek

    Adam Piątyszek - 2006-10-06

    Logged In: YES
    user_id=1004597

    Hi George,

    You don't have to answer to my previous post here. I have
    just commited your proposal into the repository (trunk, rev.
    666). Thanks again for providing the patch.

    BR,
    /ediap

     
  • George Jöngren

    George Jöngren - 2006-10-07

    Logged In: YES
    user_id=1164257

    Hi again!

    Thanks for including my patch. Regarding the if else in the
    macro - it is the recommended way of writing multiline
    macros. It ensures that you can write things like
    if(something)
    MACRO();

    See FAQ C++ lite http://www.parashift.com/c++-faq-lite/misc-
    technical-issues.html#faq-39.5 for a more thorough
    explanation.

    BR

    George

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks