BsTestOutput.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "Prerequisites/BsPrerequisitesUtil.h"
  5. namespace bs
  6. {
  7. /** @addtogroup Testing
  8. * @{
  9. */
  10. /** Abstract interface used for outputting unit test results. */
  11. class BS_UTILITY_EXPORT TestOutput
  12. {
  13. public:
  14. virtual ~TestOutput() {}
  15. /**
  16. * Triggered when a unit test fails.
  17. *
  18. * @param[in] desc Reason why the unit test failed.
  19. * @param[in] function Name of the function the test failed in.
  20. * @param[in] file File the unit test failed in.
  21. * @param[in] line Line of code the unit test failed on.
  22. */
  23. virtual void outputFail(const String& desc, const String& function, const String& file, long line) = 0;
  24. };
  25. /** Outputs unit test results so that failures are reported as exceptions. Success is not reported. */
  26. class BS_UTILITY_EXPORT ExceptionTestOutput : public TestOutput
  27. {
  28. public:
  29. /** @copydoc TestOutput::outputFail */
  30. void outputFail(const String& desc, const String& function, const String& file, long line) final override;
  31. };
  32. /** @} */
  33. }