Skip to content

Commit

Permalink
added clearFilters() to doctest::Context - fixed #33
Browse files Browse the repository at this point in the history
  • Loading branch information
onqtam committed Sep 21, 2016
1 parent 96bdf71 commit 31628ef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions doctest/doctest.h
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,7 @@ class Context
void applyCommandLine(int argc, const char* const* argv);

void addFilter(const char* filter, const char* value);
void clearFilters();
void setOption(const char* option, int value);
void setOption(const char* option, const char* value);

Expand Down Expand Up @@ -1726,6 +1727,7 @@ Context::Context(int, const char* const*) {}
Context::~Context() {}
void Context::applyCommandLine(int, const char* const*) {}
void Context::addFilter(const char*, const char*) {}
void Context::clearFilters() {}
void Context::setOption(const char*, int) {}
void Context::setOption(const char*, const char*) {}
bool Context::shouldExit() { return false; }
Expand Down Expand Up @@ -2688,6 +2690,12 @@ void Context::parseArgs(int argc, const char* const* argv, bool withDefaults) {
// allows the user to add procedurally to the filters from the command line
void Context::addFilter(const char* filter, const char* value) { setOption(filter, value); }

// allows the user to clear all filters from the command line
void Context::clearFilters() {
for(unsigned i = 0; i < p->filters.size(); ++i)
p->filters[i].clear();
}

// allows the user to override procedurally the int/bool options from the command line
void Context::setOption(const char* option, int value) {
setOption(option, toString(value).c_str());
Expand Down
1 change: 1 addition & 0 deletions doctest/parts/doctest_fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ class Context
void applyCommandLine(int argc, const char* const* argv);

void addFilter(const char* filter, const char* value);
void clearFilters();
void setOption(const char* option, int value);
void setOption(const char* option, const char* value);

Expand Down
7 changes: 7 additions & 0 deletions doctest/parts/doctest_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ Context::Context(int, const char* const*) {}
Context::~Context() {}
void Context::applyCommandLine(int, const char* const*) {}
void Context::addFilter(const char*, const char*) {}
void Context::clearFilters() {}
void Context::setOption(const char*, int) {}
void Context::setOption(const char*, const char*) {}
bool Context::shouldExit() { return false; }
Expand Down Expand Up @@ -1351,6 +1352,12 @@ void Context::parseArgs(int argc, const char* const* argv, bool withDefaults) {
// allows the user to add procedurally to the filters from the command line
void Context::addFilter(const char* filter, const char* value) { setOption(filter, value); }

// allows the user to clear all filters from the command line
void Context::clearFilters() {
for(unsigned i = 0; i < p->filters.size(); ++i)
p->filters[i].clear();
}

// allows the user to override procedurally the int/bool options from the command line
void Context::setOption(const char* option, int value) {
setOption(option, toString(value).c_str());
Expand Down

0 comments on commit 31628ef

Please sign in to comment.