philips-software / philips-software/amp-cucumber-cpp-runner

feat: add custom parameter based on a map of values

Open
#345 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
22
Forks
7
Avg merge
2d 5h
Merged PRs (30d)
4

Description

Currently the PARAMETER macro only accepts a regex string. But there are quite some occasions where a custom parameter is nothing more than mapping a string to values. This can for example be used to create a custom parameter based on enums:

// somewhere
enum class State{
 connected,
 disconnected,
 standby,
 shutdown
}

namespace{
  const std::map<std::string, State> stateMap{
   {"connected", State::connected},
   {"disconnected", State::disconnected},
   {"standby", State::standby},
   {"shutdown", State::shutdown},
  };
}

PARAMETER_MAP("state", stateMap, true);

// PARAMETER_MAP does the heavy lifting of transforming all the keys from the provided
// map in to a regex that would look like: `(connected|disconnected|standby|shutdown)`
// it also takes care of creating a simple implementation that takes a string
// and uses the .at function on the provided map using the captured argument
// it could potentially look something like this (pseudo-code-ish)
#define PARAMETER_MAP(name, map, snippet) \
PARAMETER(decltype(map)::value_type, (name, transformKeysToRegex(map), snippet), (const std::string& key)) \
{ \
  return map.at(key); \
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the existing PARAMETER macro definition and trace how its regex and conversion behavior are implemented. Define the map-based parameter behavior described in the issue, including transforming map keys into a matching regex and looking up the captured string with the map; done means enum-style maps can be used as custom parameters.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.