Tidy up whitespace

This commit is contained in:
Vinnie Falco
2016-08-29 10:43:56 -04:00
parent 5f8f6c0b75
commit 4bb0b9d0d9
11 changed files with 168 additions and 171 deletions

View File

@@ -23,29 +23,29 @@ private:
std::string const& what_;
public:
amount (amount const&) = default;
amount& operator= (amount const&) = delete;
amount(amount const&) = default;
amount& operator=(amount const&) = delete;
template<class = void>
amount (std::size_t n, std::string const& what);
amount(std::size_t n, std::string const& what);
friend
std::ostream&
operator<< (std::ostream& s, amount const& t);
operator<<(std::ostream& s, amount const& t);
};
template<class>
amount::amount (std::size_t n, std::string const& what)
: n_ (n)
, what_ (what)
amount::amount(std::size_t n, std::string const& what)
: n_(n)
, what_(what)
{
}
inline
std::ostream&
operator<< (std::ostream& s, amount const& t)
operator<<(std::ostream& s, amount const& t)
{
s << t.n_ << " " << t.what_ << ((t.n_ != 1) ? "s" : "");
s << t.n_ << " " << t.what_ <<((t.n_ != 1) ? "s" : "");
return s;
}

View File

@@ -45,7 +45,7 @@ print(std::ostream& os, suite_list const& c)
std::size_t manual = 0;
for(auto const& s : c)
{
os << prefix (s) << s.full_name() << '\n';
os << prefix(s) << s.full_name() << '\n';
if(s.manual())
++manual;
}
@@ -80,18 +80,18 @@ int main(int ac, char const* av[])
#ifdef _MSC_VER
{
int flags = _CrtSetDbgFlag (_CRTDBG_REPORT_FLAG);
int flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
flags |= _CRTDBG_LEAK_CHECK_DF;
_CrtSetDbgFlag (flags);
_CrtSetDbgFlag(flags);
}
#endif
namespace po = boost::program_options;
po::options_description desc("Options");
desc.add_options()
("help,h", "Produce a help message")
("print,r", "Print the list of available test suites")
("suites,s", po::value<string>(), "suites to run")
("help,h", "Produce a help message")
("print,r", "Print the list of available test suites")
("suites,s", po::value<string>(), "suites to run")
;
po::positional_options_description p;

View File

@@ -47,19 +47,19 @@ private:
public:
template<class = void>
explicit
selector (mode_t mode, std::string const& pattern = "");
selector(mode_t mode, std::string const& pattern = "");
template<class = void>
bool
operator() (suite_info const& s);
operator()(suite_info const& s);
};
//------------------------------------------------------------------------------
template<class>
selector::selector (mode_t mode, std::string const& pattern)
: mode_ (mode)
, pat_ (pattern)
selector::selector(mode_t mode, std::string const& pattern)
: mode_(mode)
, pat_(pattern)
{
if(mode_ == automatch && pattern.empty())
mode_ = all;
@@ -67,9 +67,9 @@ selector::selector (mode_t mode, std::string const& pattern)
template<class>
bool
selector::operator() (suite_info const& s)
selector::operator()(suite_info const& s)
{
switch (mode_)
switch(mode_)
{
case automatch:
// suite or full name
@@ -138,9 +138,9 @@ selector::operator() (suite_info const& s)
*/
inline
selector
match_auto (std::string const& name)
match_auto(std::string const& name)
{
return selector (selector::automatch, name);
return selector(selector::automatch, name);
}
/** Return a predicate that matches all suites not marked manual. */
@@ -148,23 +148,23 @@ inline
selector
match_all()
{
return selector (selector::all);
return selector(selector::all);
}
/** Returns a predicate that matches a specific suite. */
inline
selector
match_suite (std::string const& name)
match_suite(std::string const& name)
{
return selector (selector::suite, name);
return selector(selector::suite, name);
}
/** Returns a predicate that matches all suites in a library. */
inline
selector
match_library (std::string const& name)
match_library(std::string const& name)
{
return selector (selector::library, name);
return selector(selector::library, name);
}
} // unit_test

View File

@@ -24,8 +24,8 @@ private:
public:
recorder() = default;
recorder (recorder const&) = default;
recorder& operator= (recorder const&) = default;
recorder(recorder const&) = default;
recorder& operator=(recorder const&) = default;
/** Returns a report with the results of all completed suites. */
results const&
@@ -37,23 +37,23 @@ public:
private:
virtual
void
on_suite_begin (suite_info const& info) override
on_suite_begin(suite_info const& info) override
{
m_suite = suite_results (info.full_name());
m_suite = suite_results(info.full_name());
}
virtual
void
on_suite_end() override
{
m_results.insert (std::move (m_suite));
m_results.insert(std::move(m_suite));
}
virtual
void
on_case_begin (std::string const& name) override
on_case_begin(std::string const& name) override
{
m_case = case_results (name);
m_case = case_results(name);
}
virtual
@@ -61,7 +61,7 @@ private:
on_case_end() override
{
if(m_case.tests.size() > 0)
m_suite.insert (std::move (m_case));
m_suite.insert(std::move(m_case));
}
virtual
@@ -73,16 +73,16 @@ private:
virtual
void
on_fail (std::string const& reason) override
on_fail(std::string const& reason) override
{
m_case.tests.fail (reason);
m_case.tests.fail(reason);
}
virtual
void
on_log (std::string const& s) override
on_log(std::string const& s) override
{
m_case.log.insert (s);
m_case.log.insert(s);
}
};

View File

@@ -83,7 +83,7 @@ private:
typename clock_type::time_point start = clock_type::now();
void
add (suite_results const& r);
add(suite_results const& r);
};
std::ostream& os_;
@@ -108,7 +108,7 @@ private:
virtual
void
on_suite_begin (suite_info const& info) override;
on_suite_begin(suite_info const& info) override;
virtual
void
@@ -116,7 +116,7 @@ private:
virtual
void
on_case_begin (std::string const& name) override;
on_case_begin(std::string const& name) override;
virtual
void
@@ -128,11 +128,11 @@ private:
virtual
void
on_fail (std::string const& reason) override;
on_fail(std::string const& reason) override;
virtual
void
on_log (std::string const& s) override;
on_log(std::string const& s) override;
};
//------------------------------------------------------------------------------
@@ -218,7 +218,7 @@ reporter<_>::fmtdur(typename clock_type::duration const& d)
return std::to_string(ms.count()) + "ms";
std::stringstream ss;
ss << std::fixed << std::setprecision(1) <<
(ms.count()/1000.) << "s";
(ms.count()/1000.) << "s";
return ss.str();
}
@@ -243,8 +243,8 @@ void
reporter<_>::
on_case_begin(std::string const& name)
{
case_results_ = case_results (name);
if(!prefixed_)
case_results_ = case_results(name);
if(! prefixed_)
{
os_ << suite_results_.name <<
(case_results_.name.empty() ? "" :
@@ -278,7 +278,7 @@ on_fail(std::string const& reason)
++case_results_.total;
os_ <<
"#" << case_results_.total << " failed" <<
(reason.empty() ? "" : ": ") << reason << std::endl;
(reason.empty() ? "" : ": ") << reason << std::endl;
}
template<class _>

View File

@@ -23,14 +23,14 @@ public:
/** Holds the result of evaluating one test condition. */
struct test
{
explicit test (bool pass_)
: pass (pass_)
explicit test(bool pass_)
: pass(pass_)
{
}
test (bool pass_, std::string const& reason_)
: pass (pass_)
, reason (reason_)
test(bool pass_, std::string const& reason_)
: pass(pass_)
, reason(reason_)
{
}
@@ -47,7 +47,7 @@ private:
public:
tests_t()
: failed_ (0)
: failed_(0)
{
}
@@ -69,15 +69,15 @@ private:
void
pass()
{
cont().emplace_back (true);
cont().emplace_back(true);
}
/** Register a failed test condition. */
void
fail (std::string const& reason = "")
fail(std::string const& reason = "")
{
++failed_;
cont().emplace_back (false, reason);
cont().emplace_back(false, reason);
}
};
@@ -87,17 +87,17 @@ private:
public:
/** Insert a string into the log. */
void
insert (std::string const& s)
insert(std::string const& s)
{
cont().push_back (s);
cont().push_back(s);
}
};
std::string name_;
public:
explicit case_results (std::string const& name = "")
: name_ (name)
explicit case_results(std::string const& name = "")
: name_(name)
{
}
@@ -127,8 +127,8 @@ private:
std::size_t failed_ = 0;
public:
explicit suite_results (std::string const& name = "")
: name_ (name)
explicit suite_results(std::string const& name = "")
: name_(name)
{
}
@@ -156,17 +156,17 @@ public:
/** Insert a set of testcase results. */
/** @{ */
void
insert (case_results&& r)
insert(case_results&& r)
{
cont().emplace_back (std::move (r));
cont().emplace_back(std::move(r));
total_ += r.tests.total();
failed_ += r.tests.failed();
}
void
insert (case_results const& r)
insert(case_results const& r)
{
cont().push_back (r);
cont().push_back(r);
total_ += r.tests.total();
failed_ += r.tests.failed();
}
@@ -187,9 +187,9 @@ private:
public:
results()
: m_cases (0)
, total_ (0)
, failed_ (0)
: m_cases(0)
, total_(0)
, failed_(0)
{
}
@@ -217,21 +217,21 @@ public:
/** Insert a set of suite results. */
/** @{ */
void
insert (suite_results&& r)
insert(suite_results&& r)
{
m_cases += r.size();
total_ += r.total();
failed_ += r.failed();
cont().emplace_back (std::move (r));
cont().emplace_back(std::move(r));
}
void
insert (suite_results const& r)
insert(suite_results const& r)
{
m_cases += r.size();
total_ += r.total();
failed_ += r.failed();
cont().push_back (r);
cont().push_back(r);
}
/** @} */
};

View File

@@ -18,6 +18,7 @@ namespace beast {
namespace unit_test {
/** Unit test runner interface.
Derived classes can customize the reporting behavior. This interface is
injected into the unit_test class to receive the results of the tests.
*/
@@ -60,7 +61,7 @@ public:
*/
template<class = void>
bool
run (suite_info const& s);
run(suite_info const& s);
/** Run a sequence of suites.
The expression
@@ -70,12 +71,12 @@ public:
*/
template<class FwdIter>
bool
run (FwdIter first, FwdIter last);
run(FwdIter first, FwdIter last);
/** Conditionally run a sequence of suites.
pred will be called as:
@code
bool pred (suite_info const&);
bool pred(suite_info const&);
@endcode
@return `true` if any conditions failed.
*/
@@ -88,12 +89,12 @@ public:
*/
template<class SequenceContainer>
bool
run_each (SequenceContainer const& c);
run_each(SequenceContainer const& c);
/** Conditionally run suites in a container.
pred will be called as:
@code
bool pred (suite_info const&);
bool pred(suite_info const&);
@endcode
@return `true` if any conditions failed.
*/
@@ -102,10 +103,6 @@ public:
run_each_if(SequenceContainer const& c, Pred pred = Pred{});
protected:
//
// Overrides
//
/// Called when a new suite starts.
virtual
void
@@ -161,7 +158,7 @@ private:
// Start a new testcase.
template<class = void>
void
testcase (std::string const& name);
testcase(std::string const& name);
template<class = void>
void
@@ -169,26 +166,26 @@ private:
template<class = void>
void
fail (std::string const& reason);
fail(std::string const& reason);
template<class = void>
void
log (std::string const& s);
log(std::string const& s);
};
//------------------------------------------------------------------------------
template<class>
bool
runner::run (suite_info const& s)
runner::run(suite_info const& s)
{
// Enable 'default' testcase
default_ = true;
failed_ = false;
on_suite_begin (s);
s.run (*this);
on_suite_begin(s);
s.run(*this);
// Forgot to call pass or fail.
assert (cond_);
assert(cond_);
on_case_end();
on_suite_end();
return failed_;
@@ -196,11 +193,11 @@ runner::run (suite_info const& s)
template<class FwdIter>
bool
runner::run (FwdIter first, FwdIter last)
runner::run(FwdIter first, FwdIter last)
{
bool failed (false);
bool failed(false);
for(;first != last; ++first)
failed = run (*first) || failed;
failed = run(*first) || failed;
return failed;
}
@@ -208,20 +205,20 @@ template<class FwdIter, class Pred>
bool
runner::run_if(FwdIter first, FwdIter last, Pred pred)
{
bool failed (false);
bool failed(false);
for(;first != last; ++first)
if(pred (*first))
failed = run (*first) || failed;
if(pred(*first))
failed = run(*first) || failed;
return failed;
}
template<class SequenceContainer>
bool
runner::run_each (SequenceContainer const& c)
runner::run_each(SequenceContainer const& c)
{
bool failed (false);
bool failed(false);
for(auto const& s : c)
failed = run (s) || failed;
failed = run(s) || failed;
return failed;
}
@@ -229,27 +226,27 @@ template<class SequenceContainer, class Pred>
bool
runner::run_each_if(SequenceContainer const& c, Pred pred)
{
bool failed (false);
bool failed(false);
for(auto const& s : c)
if(pred (s))
failed = run (s) || failed;
if(pred(s))
failed = run(s) || failed;
return failed;
}
template<class>
void
runner::testcase (std::string const& name)
runner::testcase(std::string const& name)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
// Name may not be empty
assert (default_ || ! name.empty());
assert(default_ || ! name.empty());
// Forgot to call pass or fail
assert (default_ || cond_);
assert(default_ || cond_);
if(! default_)
on_case_end();
default_ = false;
cond_ = false;
on_case_begin (name);
on_case_begin(name);
}
template<class>
@@ -258,31 +255,31 @@ runner::pass()
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
if(default_)
testcase ("");
testcase("");
on_pass();
cond_ = true;
}
template<class>
void
runner::fail (std::string const& reason)
runner::fail(std::string const& reason)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
if(default_)
testcase ("");
on_fail (reason);
testcase("");
on_fail(reason);
failed_ = true;
cond_ = true;
}
template<class>
void
runner::log (std::string const& s)
runner::log(std::string const& s)
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
if(default_)
testcase ("");
on_log (s);
testcase("");
on_log(s);
}
} // unit_test

View File

@@ -165,7 +165,7 @@ public:
*/
template<class = void>
void
operator() (runner& r);
operator()(runner& r);
/** Evaluate a test condition.
The condition is passed as a template argument instead of `bool` so
@@ -189,11 +189,11 @@ public:
/** @{ */
template<class F, class String>
bool
except (F&& f, String const& reason);
except(F&& f, String const& reason);
template<class F>
bool
except (F&& f)
except(F&& f)
{
return except(f, "");
}
@@ -203,11 +203,11 @@ public:
/** @{ */
template<class E, class F, class String>
bool
except (F&& f, String const& reason);
except(F&& f, String const& reason);
template<class E, class F>
bool
except (F&& f)
except(F&& f)
{
return except<E>(f, "");
}
@@ -217,11 +217,11 @@ public:
/** @{ */
template<class F, class String>
bool
unexcept (F&& f, String const& reason);
unexcept(F&& f, String const& reason);
template<class F>
bool
unexcept (F&& f)
unexcept(F&& f)
{
return unexcept(f, "");
}
@@ -235,17 +235,17 @@ public:
}
// DEPRECATED
// @return `true` if the test condition indicates success (a false value)
// @return `true` if the test condition indicates success(a false value)
template<class Condition, class String>
bool
unexpected (Condition shouldBeFalse,
unexpected(Condition shouldBeFalse,
String const& reason);
template<class Condition>
bool
unexpected (Condition shouldBeFalse)
unexpected(Condition shouldBeFalse)
{
return unexpected (shouldBeFalse, "");
return unexpected(shouldBeFalse, "");
}
/** Record a successful test condition. */
@@ -256,7 +256,7 @@ public:
/** Record a failure. */
template<class = void>
void
fail (std::string const& reason = "");
fail(std::string const& reason = "");
private:
friend class thread;
@@ -279,7 +279,7 @@ private:
template<class = void>
void
run (runner& r);
run(runner& r);
};
//------------------------------------------------------------------------------
@@ -298,7 +298,7 @@ public:
{
auto const& name = ss_.str();
if(! name.empty())
suite_.runner_->testcase (name);
suite_.runner_->testcase(name);
}
scoped_testcase(suite& self, std::stringstream& ss)
@@ -333,16 +333,16 @@ public:
inline
void
suite::testcase_t::operator() (std::string const& name,
suite::testcase_t::operator()(std::string const& name,
abort_t abort)
{
suite_.abort_ = abort == abort_on_fail;
suite_.runner_->testcase (name);
suite_.runner_->testcase(name);
}
inline
suite::scoped_testcase
suite::testcase_t::operator() (abort_t abort)
suite::testcase_t::operator()(abort_t abort)
{
suite_.abort_ = abort == abort_on_fail;
return { suite_, ss_ };
@@ -351,7 +351,7 @@ suite::testcase_t::operator() (abort_t abort)
template<class T>
inline
suite::scoped_testcase
suite::testcase_t::operator<< (T const& t)
suite::testcase_t::operator<<(T const& t)
{
return { suite_, ss_, t };
}
@@ -392,7 +392,7 @@ suite::expect(Condition const& shouldBeTrue,
template<class F, class String>
bool
suite::except (F&& f, String const& reason)
suite::except(F&& f, String const& reason)
{
try
{
@@ -409,7 +409,7 @@ suite::except (F&& f, String const& reason)
template<class E, class F, class String>
bool
suite::except (F&& f, String const& reason)
suite::except(F&& f, String const& reason)
{
try
{
@@ -426,7 +426,7 @@ suite::except (F&& f, String const& reason)
template<class F, class String>
bool
suite::unexcept (F&& f, String const& reason)
suite::unexcept(F&& f, String const& reason)
{
try
{
@@ -444,7 +444,7 @@ suite::unexcept (F&& f, String const& reason)
template<class Condition, class String>
inline
bool
suite::unexpected (Condition shouldBeFalse,
suite::unexpected(Condition shouldBeFalse,
String const& reason)
{
bool const b =
@@ -452,7 +452,7 @@ suite::unexpected (Condition shouldBeFalse,
if(! b)
pass();
else
fail (reason);
fail(reason);
return ! b;
}
@@ -466,10 +466,10 @@ suite::pass()
template<class>
void
suite::fail (std::string const& reason)
suite::fail(std::string const& reason)
{
propagate_abort();
runner_->fail (reason);
runner_->fail(reason);
if(abort_)
{
aborted_ = true;
@@ -487,7 +487,7 @@ suite::propagate_abort()
template<class>
void
suite::run (runner& r)
suite::run(runner& r)
{
runner_ = &r;
@@ -495,18 +495,18 @@ suite::run (runner& r)
{
run();
}
catch (abort_exception const&)
catch(abort_exception const&)
{
// ends the suite
}
catch (std::exception const& e)
catch(std::exception const& e)
{
runner_->fail ("unhandled exception: " +
std::string (e.what()));
runner_->fail("unhandled exception: " +
std::string(e.what()));
}
catch (...)
catch(...)
{
runner_->fail ("unhandled exception");
runner_->fail("unhandled exception");
}
}
@@ -527,7 +527,7 @@ suite::run (runner& r)
// This inserts the suite with the given manual flag
#define BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,manual) \
static beast::unit_test::detail::insert_suite <Class##_test> \
Library ## Module ## Class ## _test_instance ( \
Library ## Module ## Class ## _test_instance( \
#Class, #Module, #Library, manual)
//------------------------------------------------------------------------------

View File

@@ -80,7 +80,7 @@ public:
void
run(runner& r) const
{
run_ (r);
run_(r);
}
friend

View File

@@ -56,14 +56,14 @@ suite_list::insert(
{
std::string s;
s = std::string(library) + "." + module + "." + name;
auto const result (names_.insert(s));
assert (result.second); // Duplicate name
auto const result(names_.insert(s));
assert(result.second); // Duplicate name
}
{
auto const result (classes_.insert (
std::type_index (typeid(Suite))));
assert (result.second); // Duplicate type
auto const result(classes_.insert(
std::type_index(typeid(Suite))));
assert(result.second); // Duplicate type
}
#endif
cont().emplace(make_suite_info<Suite>(

View File

@@ -28,16 +28,16 @@ public:
using native_handle_type = std::thread::native_handle_type;
thread() = default;
thread (thread const&) = delete;
thread& operator= (thread const&) = delete;
thread(thread const&) = delete;
thread& operator=(thread const&) = delete;
thread (thread&& other)
: s_ (other.s_)
, t_ (std::move(other.t_))
thread(thread&& other)
: s_(other.s_)
, t_(std::move(other.t_))
{
}
thread& operator= (thread&& other)
thread& operator=(thread&& other)
{
s_ = other.s_;
t_ = std::move(other.t_);
@@ -46,13 +46,13 @@ public:
template<class F, class... Args>
explicit
thread (suite& s, F&& f, Args&&... args)
: s_ (&s)
thread(suite& s, F&& f, Args&&... args)
: s_(&s)
{
std::function<void(void)> b =
std::bind(std::forward<F>(f),
std::forward<Args>(args)...);
t_ = std::thread (&thread::run, this,
t_ = std::thread(&thread::run, this,
std::move(b));
}
@@ -89,7 +89,7 @@ public:
}
void
swap (thread& other)
swap(thread& other)
{
std::swap(s_, other.s_);
std::swap(t_, other.t_);
@@ -97,23 +97,23 @@ public:
private:
void
run (std::function <void(void)> f)
run(std::function <void(void)> f)
{
try
{
f();
}
catch (suite::abort_exception const&)
catch(suite::abort_exception const&)
{
}
catch (std::exception const& e)
catch(std::exception const& e)
{
s_->fail ("unhandled exception: " +
std::string (e.what()));
s_->fail("unhandled exception: " +
std::string(e.what()));
}
catch (...)
catch(...)
{
s_->fail ("unhandled exception");
s_->fail("unhandled exception");
}
}
};