home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 275 / DPCS0111DVD.ISO / Toolkit / Audio-Visual / VirtualDub / Source / VirtualDub-1.9.10-src.7z / src / test / h / test.h
Encoding:
C/C++ Source or Header  |  2009-09-14  |  882 b   |  23 lines

  1. #ifndef f_TEST_H
  2. #define f_TEST_H
  3.  
  4. #include <vd2/system/error.h>
  5.  
  6. typedef int (*TestFn)();
  7.  
  8. extern void AddTest(TestFn, const char *, bool autoRun);
  9.  
  10. #define DEFINE_TEST(name) int Test##name(); namespace { struct TestAutoInit_##name { TestAutoInit_##name() { AddTest(Test##name, #name, true); } } g_testAutoInit_##name; } int Test##name()
  11. #define DEFINE_TEST_NONAUTO(name) int Test##name(); namespace { struct TestAutoInit_##name { TestAutoInit_##name() { AddTest(Test##name, #name, false); } } g_testAutoInit_##name; } int Test##name()
  12.  
  13. class AssertionException : public MyError {
  14. public:
  15.     AssertionException(const char *s) : MyError(s) {}
  16. };
  17.  
  18. bool ShouldBreak();
  19.  
  20. #define TEST_ASSERT(condition) if (!(condition)) { ShouldBreak() ? __debugbreak() : throw AssertionException("Test assertion failed: " #condition); volatile int _x = 0; } else ((void)0)
  21.  
  22. #endif
  23.