File indexing completed on 2025-01-30 10:02:51
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef CATCH_TEST_SPEC_PARSER_HPP_INCLUDED
0009 #define CATCH_TEST_SPEC_PARSER_HPP_INCLUDED
0010
0011 #ifdef __clang__
0012 #pragma clang diagnostic push
0013 #pragma clang diagnostic ignored "-Wpadded"
0014 #endif
0015
0016 #include <catch2/catch_test_spec.hpp>
0017
0018 #include <vector>
0019 #include <string>
0020
0021 namespace Catch {
0022
0023 class ITagAliasRegistry;
0024
0025 class TestSpecParser {
0026 enum Mode{ None, Name, QuotedName, Tag, EscapedName };
0027 Mode m_mode = None;
0028 Mode lastMode = None;
0029 bool m_exclusion = false;
0030 std::size_t m_pos = 0;
0031 std::size_t m_realPatternPos = 0;
0032 std::string m_arg;
0033 std::string m_substring;
0034 std::string m_patternName;
0035 std::vector<std::size_t> m_escapeChars;
0036 TestSpec::Filter m_currentFilter;
0037 TestSpec m_testSpec;
0038 ITagAliasRegistry const* m_tagAliases = nullptr;
0039
0040 public:
0041 TestSpecParser( ITagAliasRegistry const& tagAliases );
0042
0043 TestSpecParser& parse( std::string const& arg );
0044 TestSpec testSpec();
0045
0046 private:
0047 bool visitChar( char c );
0048 void startNewMode( Mode mode );
0049 bool processNoneChar( char c );
0050 void processNameChar( char c );
0051 bool processOtherChar( char c );
0052 void endMode();
0053 void escape();
0054 bool isControlChar( char c ) const;
0055 void saveLastMode();
0056 void revertBackToLastMode();
0057 void addFilter();
0058 bool separate();
0059
0060
0061 std::string preprocessPattern();
0062
0063 void addNamePattern();
0064
0065 void addTagPattern();
0066
0067 inline void addCharToPattern(char c) {
0068 m_substring += c;
0069 m_patternName += c;
0070 m_realPatternPos++;
0071 }
0072
0073 };
0074
0075 }
0076
0077 #ifdef __clang__
0078 #pragma clang diagnostic pop
0079 #endif
0080
0081 #endif