| 8 | using namespace cucumber::internal; |
| 9 | |
| 10 | class StepManagerTest : public ::testing::Test { |
| 11 | public: |
| 12 | typedef StepManagerTestDouble StepManager; |
| 13 | |
| 14 | protected: |
| 15 | StepManagerTest() { |
| 16 | } |
| 17 | const static char* a_matcher; |
| 18 | const static char* another_matcher; |
| 19 | const static char* no_match; |
| 20 | const static char* a_third_matcher; |
| 21 | const map<std::ptrdiff_t, string> no_params; |
| 22 | |
| 23 | int getUniqueMatchIdOrZeroFor(const string& stepMatch) { |
| 24 | MatchResult::match_results_type resultSet = getResultSetFor(stepMatch); |
| 25 | if (resultSet.size() != 1) { |
| 26 | return 0; |
| 27 | } else { |
| 28 | return resultSet.begin()->stepInfo->id; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | size_t countMatches(const string& stepMatch) { |
| 33 | return getResultSetFor(stepMatch).size(); |
| 34 | } |
| 35 | |
| 36 | bool matchesOnce(const string& stepMatch) { |
| 37 | return (countMatches(stepMatch) == 1); |
| 38 | } |
| 39 | |
| 40 | bool matchesAtLeastOnce(const string& stepMatch) { |
| 41 | return (countMatches(stepMatch) > 0); |
| 42 | } |
| 43 | |
| 44 | bool extractedParamsAre(const string stepMatch, map<std::ptrdiff_t, string> params) { |
| 45 | MatchResult::match_results_type resultSet = getResultSetFor(stepMatch); |
| 46 | if (resultSet.size() != 1) { |
| 47 | return false; // more than one match |
| 48 | } |
| 49 | SingleStepMatch match = resultSet.front(); |
| 50 | if (params.size() != match.submatches.size()) { |
| 51 | return false; |
| 52 | } |
| 53 | SingleStepMatch::submatches_type::const_iterator rsi; |
| 54 | for (rsi = match.submatches.begin(); rsi != match.submatches.end(); ++rsi) { |
| 55 | if (params.find(rsi->position) == params.end()) |
| 56 | return false; |
| 57 | if (rsi->value != params[rsi->position]) { |
| 58 | return false; |
| 59 | } |
| 60 | } |
| 61 | return true; |
| 62 | } |
| 63 | |
| 64 | private: |
| 65 | MatchResult::match_results_type getResultSetFor(const string& stepMatch) { |
| 66 | return StepManager::stepMatches(stepMatch).getResultSet(); |
| 67 | } |
nothing calls this directly
no outgoing calls
no test coverage detected