test_suite.hpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include <cstdint>
  3. #include <functional>
  4. #include <iostream>
  5. #include <string>
  6. #include <utility>
  7. #include <vector>
  8. #include <helpers/assertions.hpp>
  9. #include <helpers/path_helper.hpp>
  10. //#include <helpers/temporary_directory.hpp>
  11. //#include <helpers/temporary_file.hpp>
  12. #include <helpers/timing.hpp>
  13. #include <helpers/xml_helper.hpp>
  14. struct test_status
  15. {
  16. std::size_t tests_run = 0;
  17. std::size_t tests_failed = 0;
  18. std::size_t tests_passed = 0;
  19. std::vector<std::string> failures;
  20. };
  21. std::string build_name(const std::string &pretty, const std::string &method);
  22. #define register_test(test) register_test_internal([this]() { test(); }, build_name(__FUNCTION__, #test));
  23. class test_suite
  24. {
  25. public:
  26. static test_status go();
  27. protected:
  28. static void register_test_internal(std::function<void()> t, const std::string &function)
  29. {
  30. tests().push_back(std::make_pair(t, function));
  31. }
  32. private:
  33. static std::vector<std::pair<std::function<void(void)>, std::string>> &tests();
  34. };