C++DB is the database layer that was designed to work with C++CMS. This customized version is used within Ye Ol' Pi Shack.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

43 lines
1.7 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 2010-2011 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
  4. //
  5. // Distributed under:
  6. //
  7. // the Boost Software License, Version 1.0.
  8. // (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. //
  11. // or (at your opinion) under:
  12. //
  13. // The MIT License
  14. // (See accompanying file MIT.txt or a copy at
  15. // http://www.opensource.org/licenses/mit-license.php)
  16. //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #ifndef CPPDB_TEST_H
  19. #define CPPDB_TEST_H
  20. #include <sstream>
  21. #include <iostream>
  22. #include <stdexcept>
  23. #include <memory>
  24. #include <stdlib.h>
  25. int last_line = 0;
  26. int passed = 0;
  27. int failed = 0;
  28. #define TEST(x) do { last_line = __LINE__; if(x) { passed ++; break; } failed++; std::cerr<<"Failed in " << __LINE__ <<' '<< #x << std::endl; } while(0)
  29. #define THROWS(x,ex) do { last_line = __LINE__; try { x ; failed++; std::cerr << "Failed in " << __LINE__ <<' '<< #x << std::endl; }catch(ex const &/*un*/) { passed++; } } while(0)
  30. #endif
  31. #define CATCH_BLOCK() catch(std::exception const &e) { std::cerr << "Fail " << e.what() << std::endl; std::cerr << "Last tested line " << last_line << std::endl; failed++; }
  32. #define SUMMARY() do {\
  33. std::cout << "Tests: " << passed+failed << " failed: " << failed << std::endl; \
  34. if(failed > 0) { std::cerr << "Fail!" << std::endl; return 1; } \
  35. std::cout << "Ok" << std::endl; \
  36. return 0; \
  37. } while(0)