catch_test_case_info.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Created by Phil on 29/10/2010.
  3. * Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
  4. *
  5. * Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. */
  8. #ifndef TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED
  9. #define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED
  10. #include "catch_common.h"
  11. #include "catch_test_registry.h"
  12. #include <string>
  13. #include <vector>
  14. #include <memory>
  15. #ifdef __clang__
  16. #pragma clang diagnostic push
  17. #pragma clang diagnostic ignored "-Wpadded"
  18. #endif
  19. namespace Catch {
  20. struct ITestInvoker;
  21. struct TestCaseInfo {
  22. enum SpecialProperties{
  23. None = 0,
  24. IsHidden = 1 << 1,
  25. ShouldFail = 1 << 2,
  26. MayFail = 1 << 3,
  27. Throws = 1 << 4,
  28. NonPortable = 1 << 5,
  29. Benchmark = 1 << 6
  30. };
  31. TestCaseInfo( std::string const& _name,
  32. std::string const& _className,
  33. std::string const& _description,
  34. std::vector<std::string> const& _tags,
  35. SourceLineInfo const& _lineInfo );
  36. friend void setTags( TestCaseInfo& testCaseInfo, std::vector<std::string> tags );
  37. bool isHidden() const;
  38. bool throws() const;
  39. bool okToFail() const;
  40. bool expectedToFail() const;
  41. std::string tagsAsString() const;
  42. std::string name;
  43. std::string className;
  44. std::string description;
  45. std::vector<std::string> tags;
  46. std::vector<std::string> lcaseTags;
  47. SourceLineInfo lineInfo;
  48. SpecialProperties properties;
  49. };
  50. class TestCase : public TestCaseInfo {
  51. public:
  52. TestCase( ITestInvoker* testCase, TestCaseInfo&& info );
  53. TestCase withName( std::string const& _newName ) const;
  54. void invoke() const;
  55. TestCaseInfo const& getTestCaseInfo() const;
  56. bool operator == ( TestCase const& other ) const;
  57. bool operator < ( TestCase const& other ) const;
  58. private:
  59. std::shared_ptr<ITestInvoker> test;
  60. };
  61. TestCase makeTestCase( ITestInvoker* testCase,
  62. std::string const& className,
  63. NameAndTags const& nameAndTags,
  64. SourceLineInfo const& lineInfo );
  65. }
  66. #ifdef __clang__
  67. #pragma clang diagnostic pop
  68. #endif
  69. #endif // TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED