Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. class TestNotPassedException : public std::exception {
  2. public:
  3. TestNotPassedException() : m_errMessage("Some test failed.\n"){};
  4. explicit TestNotPassedException(const char* msg) : m_errMessage(msg) {}
  5.  
  6. virtual const char* what() const throw() {
  7. return m_errMessage;
  8. }
  9. private:
  10. const char* m_errMessage;
  11. };
  12.  
  13.  
  14. define ASSERT_EQUAL(first, second) do { \
  15. if (first != second) { \
  16. std::ostringstream oss; \
  17. oss << "Required equal failed: " << #first << " != " << #second << "\n" \
  18. << "At " << __FILE__ << " : " << __LINE__ << "\n"; \
  19. throw TestNotPassedException(oss.str().c_str()); \
  20. }\
  21. }while (false)
  22.  
  23.  
  24. int runTests() {
  25. try {
  26. TestCreate();
  27. } catch (std::exception& e) {
  28. std::cerr << "Tests failed\n";
  29. std::cerr << e.what();
  30. return 1;
  31. }
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement