Ocean
Loading...
Searching...
No Matches
Ocean::Test::TestSelector Class Reference

This class implements a test selector that parses test function strings and determines which tests should be executed. More...

#include <TestSelector.h>

Public Member Functions

 TestSelector (const std::string &testFunctions=std::string())
 Creates a new test selector from a comma-separated list of test function names.
 
TestSelector shouldRun (const std::string &testName) const
 Determines whether a test with the given name should be executed and returns a sub-selector for hierarchical filtering.
 
 operator bool () const
 Bool conversion operator to check if this selector indicates the test should run.
 
bool runAll () const
 Returns whether all tests should be executed.
 

Protected Types

using Patterns = std::unordered_set< std::string >
 Definition of an unordered set holding test patterns.
 

Private Member Functions

 TestSelector (Patterns &&patterns, bool shouldExecute)
 Creates a sub-selector for hierarchical test filtering.
 

Static Private Member Functions

static bool matches (const std::string &pattern, const std::string &testName)
 Checks if a pattern matches a test name.
 

Private Attributes

Patterns patterns_
 Set of test patterns parsed from the input string.
 
bool shouldExecute_ = true
 Whether tests matching this selector should execute.
 

Detailed Description

This class implements a test selector that parses test function strings and determines which tests should be executed.

The selector supports hierarchical test names with dot notation (e.g., "frameconverter.rgb24.normal") and wildcard patterns.

Usage examples:

  • Empty string: runs all tests
  • "frameconverter": runs the frameconverter test and all its sub-tests
  • "frameconverter*": runs all tests starting with "frameconverter"
  • "frameconverterrgb24.rgb24tobgr24": runs only that specific sub-test
  • "test1,test2,test3": runs test1, test2, and test3

Hierarchical matching example:

TestSelector selector("datatype.char,frame");
if (TestSelector subSelector = selector.shouldRun("datatype"))
{
// subSelector now contains only "char" (prefix "datatype." is stripped)
if (subSelector.shouldRun("char")) // This will match!
{
// Run char test
}
}
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
TestSelector shouldRun(const std::string &testName) const
Determines whether a test with the given name should be executed and returns a sub-selector for hiera...

Member Typedef Documentation

◆ Patterns

using Ocean::Test::TestSelector::Patterns = std::unordered_set<std::string>
protected

Definition of an unordered set holding test patterns.

Constructor & Destructor Documentation

◆ TestSelector() [1/2]

Ocean::Test::TestSelector::TestSelector ( const std::string &  testFunctions = std::string())
explicit

Creates a new test selector from a comma-separated list of test function names.

Test names are converted to lowercase automatically.

Parameters
testFunctionsComma-separated list of test names, wildcards, or hierarchical test identifiers; empty string means run all tests

◆ TestSelector() [2/2]

Ocean::Test::TestSelector::TestSelector ( Patterns &&  patterns,
bool  shouldExecute 
)
private

Creates a sub-selector for hierarchical test filtering.

Parameters
patternsThe patterns for this selector
shouldExecuteWhether tests matching this selector should execute

Member Function Documentation

◆ matches()

static bool Ocean::Test::TestSelector::matches ( const std::string &  pattern,
const std::string &  testName 
)
staticprivate

Checks if a pattern matches a test name.

Parameters
patternThe pattern to match against (may contain wildcards), must be valid
testNameThe test name to check, must be valid
Returns
True if the pattern matches the test name

◆ operator bool()

Ocean::Test::TestSelector::operator bool ( ) const
explicit

Bool conversion operator to check if this selector indicates the test should run.

Returns
True if the test should execute, false otherwise

◆ runAll()

bool Ocean::Test::TestSelector::runAll ( ) const
inline

Returns whether all tests should be executed.

Returns
True if no specific patterns were provided (empty string), false otherwise

◆ shouldRun()

TestSelector Ocean::Test::TestSelector::shouldRun ( const std::string &  testName) const

Determines whether a test with the given name should be executed and returns a sub-selector for hierarchical filtering.

Parameters
testNameThe name of the test to check (case-insensitive), must be valid
Returns
A TestSelector that can be cast to bool (true if test should run) and contains stripped sub-patterns

Field Documentation

◆ patterns_

Patterns Ocean::Test::TestSelector::patterns_
private

Set of test patterns parsed from the input string.

◆ shouldExecute_

bool Ocean::Test::TestSelector::shouldExecute_ = true
private

Whether tests matching this selector should execute.


The documentation for this class was generated from the following file: