catch_wildcard_pattern.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Created by Phil on 13/7/2015.
  3. * Copyright 2015 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_WILDCARD_PATTERN_HPP_INCLUDED
  9. #define TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED
  10. #include "catch_common.h"
  11. namespace Catch
  12. {
  13. class WildcardPattern {
  14. enum WildcardPosition {
  15. NoWildcard = 0,
  16. WildcardAtStart = 1,
  17. WildcardAtEnd = 2,
  18. WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd
  19. };
  20. public:
  21. WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity );
  22. virtual ~WildcardPattern() = default;
  23. virtual bool matches( std::string const& str ) const;
  24. private:
  25. std::string normaliseString( std::string const& str ) const;
  26. CaseSensitive::Choice m_caseSensitivity;
  27. WildcardPosition m_wildcard = NoWildcard;
  28. std::string m_pattern;
  29. };
  30. }
  31. #endif // TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED