Removed static std::string.
which_test() doesn't have to calculate anything, could be inlined.
This commit is contained in:
parent
5dc4759598
commit
afc6d4507d
|
@ -20,9 +20,14 @@ options::options(int argc, const char* argv[])
|
||||||
:_options(&argv[1], &argv[0] + argc)
|
:_options(&argv[1], &argv[0] + argc)
|
||||||
,_gcc_style_errors(_options.count("-g") != 0)
|
,_gcc_style_errors(_options.count("-g") != 0)
|
||||||
,_quiet(_options.count("-q") != 0)
|
,_quiet(_options.count("-q") != 0)
|
||||||
|
,_which_test("")
|
||||||
{
|
{
|
||||||
_options.erase("-g");
|
_options.erase("-g");
|
||||||
_options.erase("-q");
|
_options.erase("-q");
|
||||||
|
if (not _options.empty())
|
||||||
|
{
|
||||||
|
_which_test = *_options.rbegin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool options::quiet() const
|
bool options::quiet() const
|
||||||
|
@ -37,11 +42,6 @@ bool options::gcc_style_errors() const
|
||||||
|
|
||||||
const std::string& options::which_test() const
|
const std::string& options::which_test() const
|
||||||
{
|
{
|
||||||
static std::string ret = "";
|
return _which_test;
|
||||||
if (not _options.empty())
|
|
||||||
{
|
|
||||||
ret = *_options.rbegin();
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ private:
|
||||||
std::set<std::string> _options;
|
std::set<std::string> _options;
|
||||||
const bool _gcc_style_errors;
|
const bool _gcc_style_errors;
|
||||||
const bool _quiet;
|
const bool _quiet;
|
||||||
|
std::string _which_test;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -34,6 +34,7 @@ private:
|
||||||
{
|
{
|
||||||
TEST_CASE(which_test);
|
TEST_CASE(which_test);
|
||||||
TEST_CASE(which_test_method);
|
TEST_CASE(which_test_method);
|
||||||
|
TEST_CASE(no_test_method);
|
||||||
TEST_CASE(not_quiet);
|
TEST_CASE(not_quiet);
|
||||||
TEST_CASE(quiet);
|
TEST_CASE(quiet);
|
||||||
TEST_CASE(gcc_errors);
|
TEST_CASE(gcc_errors);
|
||||||
|
@ -58,6 +59,14 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void no_test_method()
|
||||||
|
{
|
||||||
|
const char* argv[] = {"./test_runner"};
|
||||||
|
options args(sizeof argv / sizeof argv[0], argv);
|
||||||
|
ASSERT_EQUALS("", args.which_test());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void not_quiet()
|
void not_quiet()
|
||||||
{
|
{
|
||||||
const char* argv[] = {"./test_runner", "TestClass::TestMethod", "-v"};
|
const char* argv[] = {"./test_runner", "TestClass::TestMethod", "-v"};
|
||||||
|
|
Loading…
Reference in New Issue