Changeset 914


Ignore:
Timestamp:
Sep 8, 2011, 12:21:29 AM (8 years ago)
Author:
sam
Message:

test: get rid of the need for LOLUNIT_SETUP_FIXTURE().

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lol/unit.h

    r913 r914  
    170170#define LOLUNIT_FIXTURE(FixtureName) \
    171171    class FixtureName; \
     172    template<typename T> struct Make##FixtureName \
     173    { \
     174        Make##FixtureName() { new T(); } \
     175    }; \
     176    Make##FixtureName<FixtureName> lol_unit_fixture_##FixtureName; \
    172177    static char const *LolUnitFixtureName(FixtureName *p) \
    173178    { \
     
    190195    void TestCaseName()
    191196
    192 #define LOLUNIT_SETUP_FIXTURE(ClassName) \
    193     ClassName ClassName##Test_Instance;
    194 
    195 #define LOLUNIT_ASSERT(cond) \
     197#define LOLUNIT_ASSERT_GENERIC(message, cond) \
    196198    do { \
    197199        m_asserts++; \
     
    205207            m_errorlog << "assertion failed" << std::endl; \
    206208            m_errorlog << "- Expression: " << #cond << std::endl; \
     209            m_errorlog << message; \
    207210            m_failure = true; \
    208211            return; \
     
    210213    } while(!True())
    211214
    212 #define LOLUNIT_ASSERT_EQUAL(a, b) \
     215#define LOLUNIT_ASSERT_EQUAL_GENERIC(message, a, b) \
    213216    do { \
    214217        m_asserts++; \
     
    229232    } while(!True())
    230233
    231 #define LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, t) \
     234#define LOLUNIT_ASSERT_DOUBLES_EQUAL_GENERIC(message, a, b, t) \
    232235    do { \
    233236        m_asserts++; \
     
    243246            m_errorlog << "- Actual  : " << (a) << std::endl; \
    244247            m_errorlog << "- Delta   : " << (t) << std::endl; \
     248            m_errorlog << message; \
    245249            m_failure = true; \
    246250            return; \
     
    248252    } while(!True())
    249253
     254#define LOLUNIT_FAIL(message) \
     255    do { \
     256        m_asserts++; \
     257        m_errorlog << std::endl << std::endl; \
     258        m_errorlog << ++m_failcases << ") test: " \
     259                   << LolUnitFixtureName(this) << "::" << m_currentname \
     260                   << " (F) line: " << __LINE__ << " " \
     261                   << __FILE__ << std::endl; \
     262        m_errorlog << "forced failure" << std::endl; \
     263        m_errorlog << "- " << message << std::endl; \
     264        m_failure = true; \
     265        return; \
     266    } while(!True())
     267
     268#define LOLUNIT_ASSERT(cond) \
     269    LOLUNIT_ASSERT_GENERIC("", cond)
     270
     271#define LOLUNIT_ASSERT_MESSAGE(message, cond) \
     272    LOLUNIT_ASSERT_GENERIC("- " << message << std::endl, cond)
     273
     274#define LOLUNIT_ASSERT_EQUAL(a, b) \
     275    LOLUNIT_ASSERT_EQUAL_GENERIC("", a, b)
     276
     277#define LOLUNIT_ASSERT_EQUAL_MESSAGE(message, a, b) \
     278    LOLUNIT_ASSERT_EQUAL_GENERIC("- " << message << std::endl, a, b)
     279
     280#define LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, t) \
     281    LOLUNIT_ASSERT_DOUBLES_EQUAL_GENERIC("", a, b, t)
     282
     283#define LOLUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(message, a, b, t) \
     284    LOLUNIT_ASSERT_DOUBLES_EQUAL_GENERIC("- " << message << std::endl, a, b, t)
     285
    250286} /* namespace lol */
    251287
  • trunk/test/half.cpp

    r912 r914  
    306306};
    307307
    308 LOLUNIT_SETUP_FIXTURE(HalfTest);
    309 
    310308} /* namespace lol */
    311309
  • trunk/test/matrix.cpp

    r912 r914  
    205205};
    206206
    207 LOLUNIT_SETUP_FIXTURE(MatrixTest);
    208 
    209207} /* namespace lol */
    210208
  • trunk/test/trig.cpp

    r912 r914  
    154154};
    155155
    156 LOLUNIT_SETUP_FIXTURE(TrigTest);
    157 
    158156} /* namespace lol */
    159157
Note: See TracChangeset for help on using the changeset viewer.