Kaynağa Gözat

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

legacy
Sam Hocevar sam 13 yıl önce
ebeveyn
işleme
5ab9eb3c62
4 değiştirilmiş dosya ile 42 ekleme ve 12 silme
  1. +42
    -6
      src/lol/unit.h
  2. +0
    -2
      test/half.cpp
  3. +0
    -2
      test/matrix.cpp
  4. +0
    -2
      test/trig.cpp

+ 42
- 6
src/lol/unit.h Dosyayı Görüntüle

@@ -169,6 +169,11 @@ public:

#define LOLUNIT_FIXTURE(FixtureName) \
class FixtureName; \
template<typename T> struct Make##FixtureName \
{ \
Make##FixtureName() { new T(); } \
}; \
Make##FixtureName<FixtureName> lol_unit_fixture_##FixtureName; \
static char const *LolUnitFixtureName(FixtureName *p) \
{ \
(void)p; \
@@ -189,10 +194,7 @@ public:
TestCase##TestCaseName lol_unit_test_case_##TestCaseName; \
void TestCaseName()

#define LOLUNIT_SETUP_FIXTURE(ClassName) \
ClassName ClassName##Test_Instance;

#define LOLUNIT_ASSERT(cond) \
#define LOLUNIT_ASSERT_GENERIC(message, cond) \
do { \
m_asserts++; \
if (True() && !(cond)) \
@@ -204,12 +206,13 @@ public:
<< __FILE__ << std::endl; \
m_errorlog << "assertion failed" << std::endl; \
m_errorlog << "- Expression: " << #cond << std::endl; \
m_errorlog << message; \
m_failure = true; \
return; \
} \
} while(!True())

#define LOLUNIT_ASSERT_EQUAL(a, b) \
#define LOLUNIT_ASSERT_EQUAL_GENERIC(message, a, b) \
do { \
m_asserts++; \
if (True() && (a) != (b)) \
@@ -228,7 +231,7 @@ public:
} \
} while(!True())

#define LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, t) \
#define LOLUNIT_ASSERT_DOUBLES_EQUAL_GENERIC(message, a, b, t) \
do { \
m_asserts++; \
if (True() && fabs((a) - (b)) > fabs((t))) \
@@ -242,11 +245,44 @@ public:
m_errorlog << "- Expected: " << (b) << std::endl; \
m_errorlog << "- Actual : " << (a) << std::endl; \
m_errorlog << "- Delta : " << (t) << std::endl; \
m_errorlog << message; \
m_failure = true; \
return; \
} \
} while(!True())

#define LOLUNIT_FAIL(message) \
do { \
m_asserts++; \
m_errorlog << std::endl << std::endl; \
m_errorlog << ++m_failcases << ") test: " \
<< LolUnitFixtureName(this) << "::" << m_currentname \
<< " (F) line: " << __LINE__ << " " \
<< __FILE__ << std::endl; \
m_errorlog << "forced failure" << std::endl; \
m_errorlog << "- " << message << std::endl; \
m_failure = true; \
return; \
} while(!True())

#define LOLUNIT_ASSERT(cond) \
LOLUNIT_ASSERT_GENERIC("", cond)

#define LOLUNIT_ASSERT_MESSAGE(message, cond) \
LOLUNIT_ASSERT_GENERIC("- " << message << std::endl, cond)

#define LOLUNIT_ASSERT_EQUAL(a, b) \
LOLUNIT_ASSERT_EQUAL_GENERIC("", a, b)

#define LOLUNIT_ASSERT_EQUAL_MESSAGE(message, a, b) \
LOLUNIT_ASSERT_EQUAL_GENERIC("- " << message << std::endl, a, b)

#define LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, t) \
LOLUNIT_ASSERT_DOUBLES_EQUAL_GENERIC("", a, b, t)

#define LOLUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(message, a, b, t) \
LOLUNIT_ASSERT_DOUBLES_EQUAL_GENERIC("- " << message << std::endl, a, b, t)

} /* namespace lol */

#endif // __LOL_UNIT_H__


+ 0
- 2
test/half.cpp Dosyayı Görüntüle

@@ -305,7 +305,5 @@ HalfTest::TestPair const HalfTest::pairs[] =
{ 31.0f / (1 << 19), 0x03e0 }, /* 0x1.fp-15, denormal */
};

LOLUNIT_SETUP_FIXTURE(HalfTest);

} /* namespace lol */


+ 0
- 2
test/matrix.cpp Dosyayı Görüntüle

@@ -204,7 +204,5 @@ private:
mat4 triangular, identity, invertible;
};

LOLUNIT_SETUP_FIXTURE(MatrixTest);

} /* namespace lol */


+ 0
- 2
test/trig.cpp Dosyayı Görüntüle

@@ -153,7 +153,5 @@ public:
}
};

LOLUNIT_SETUP_FIXTURE(TrigTest);

} /* namespace lol */


Yükleniyor…
İptal
Kaydet