Changeset 2705


Ignore:
Timestamp:
27/08/2010 10:20:30 (18 months ago)
Author:
chris
Message:

Reformat TEST_CHECK_THROWS macro for readability.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/lib/common/Test.h

    r2677 r2705  
    5252 
    5353// NOTE: The 0- bit is to allow this to work with stuff which has negative constants for flags (eg ConnectionException) 
    54 #define TEST_CHECK_THROWS(statement, excepttype, subtype)                                                                       \ 
    55         {                                                                                                                                                                               \ 
    56                 bool didthrow = false;                                                                                                                          \ 
     54#define TEST_CHECK_THROWS(statement, excepttype, subtype) \ 
     55        { \ 
     56                bool didthrow = false; \ 
    5757                HideExceptionMessageGuard hide; \ 
    58                 try                                                                                                                                                                     \ 
    59                 {                                                                                                                                                                       \ 
    60                         statement;                                                                                                                                              \ 
    61                 }                                                                                                                                                                       \ 
    62                 catch(excepttype &e)                                                                                                                            \ 
    63                 {                                                                                                                                                                       \ 
    64                         if(e.GetSubType() != ((unsigned int)excepttype::subtype)                                                \ 
    65                                         && e.GetSubType() != (unsigned int)(0-excepttype::subtype))                     \ 
    66                         {                                                                                                                                                               \ 
    67                                 throw;                                                                                                                                          \ 
    68                         }                                                                                                                                                               \ 
    69                         didthrow = true;                                                                                                                                \ 
    70                 }                                                                                                                                                                       \ 
    71                 catch(...)                                                                                                                                                      \ 
    72                 {                                                                                                                                                                       \ 
    73                         throw;                                                                                                                                                  \ 
    74                 }                                                                                                                                                                       \ 
    75                 if(!didthrow)                                                                                                                                           \ 
    76                 {                                                                                                                                                                       \ 
    77                         TEST_FAIL_WITH_MESSAGE("Didn't throw exception " #excepttype "(" #subtype ")")  \ 
    78                 }                                                                                                                                                                       \ 
     58                try \ 
     59                { \ 
     60                        statement; \ 
     61                } \ 
     62                catch(excepttype &e) \ 
     63                { \ 
     64                        if(e.GetSubType() != ((unsigned int)excepttype::subtype) \ 
     65                                        && e.GetSubType() != (unsigned int)(0-excepttype::subtype)) \ 
     66                        { \ 
     67                                throw; \ 
     68                        } \ 
     69                        didthrow = true; \ 
     70                } \ 
     71                catch(...) \ 
     72                { \ 
     73                        throw; \ 
     74                } \ 
     75                if(!didthrow) \ 
     76                { \ 
     77                        TEST_FAIL_WITH_MESSAGE("Didn't throw exception " #excepttype "(" #subtype ")") \ 
     78                } \ 
    7979        } 
    8080 
     
    9292        if(_exp_str != _found_str) \ 
    9393        { \ 
    94                 BOX_WARNING("Expected <" << _exp_str << "> but found <" << \ 
    95                         _found_str << ">"); \ 
     94                printf("Expected <%s> but found <%s>\n", \ 
     95                        _exp_str.c_str(), _found_str.c_str()); \ 
    9696                \ 
    9797                std::ostringstream _oss3; \ 
     
    127127        } \ 
    128128} 
    129  
    130129 
    131130// utility macro for testing a line 
Note: See TracChangeset for help on using the changeset viewer.