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_; std::string const& what_;
public: public:
amount (amount const&) = default; amount(amount const&) = default;
amount& operator= (amount const&) = delete; amount& operator=(amount const&) = delete;
template<class = void> template<class = void>
amount (std::size_t n, std::string const& what); amount(std::size_t n, std::string const& what);
friend friend
std::ostream& std::ostream&
operator<< (std::ostream& s, amount const& t); operator<<(std::ostream& s, amount const& t);
}; };
template<class> template<class>
amount::amount (std::size_t n, std::string const& what) amount::amount(std::size_t n, std::string const& what)
: n_ (n) : n_(n)
, what_ (what) , what_(what)
{ {
} }
inline inline
std::ostream& 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; return s;
} }

View File

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

View File

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

View File

@@ -24,8 +24,8 @@ private:
public: public:
recorder() = default; recorder() = default;
recorder (recorder const&) = default; recorder(recorder const&) = default;
recorder& operator= (recorder const&) = default; recorder& operator=(recorder const&) = default;
/** Returns a report with the results of all completed suites. */ /** Returns a report with the results of all completed suites. */
results const& results const&
@@ -37,23 +37,23 @@ public:
private: private:
virtual virtual
void 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 virtual
void void
on_suite_end() override on_suite_end() override
{ {
m_results.insert (std::move (m_suite)); m_results.insert(std::move(m_suite));
} }
virtual virtual
void 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 virtual
@@ -61,7 +61,7 @@ private:
on_case_end() override on_case_end() override
{ {
if(m_case.tests.size() > 0) if(m_case.tests.size() > 0)
m_suite.insert (std::move (m_case)); m_suite.insert(std::move(m_case));
} }
virtual virtual
@@ -73,16 +73,16 @@ private:
virtual virtual
void 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 virtual
void 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(); typename clock_type::time_point start = clock_type::now();
void void
add (suite_results const& r); add(suite_results const& r);
}; };
std::ostream& os_; std::ostream& os_;
@@ -108,7 +108,7 @@ private:
virtual virtual
void void
on_suite_begin (suite_info const& info) override; on_suite_begin(suite_info const& info) override;
virtual virtual
void void
@@ -116,7 +116,7 @@ private:
virtual virtual
void void
on_case_begin (std::string const& name) override; on_case_begin(std::string const& name) override;
virtual virtual
void void
@@ -128,11 +128,11 @@ private:
virtual virtual
void void
on_fail (std::string const& reason) override; on_fail(std::string const& reason) override;
virtual virtual
void 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"; return std::to_string(ms.count()) + "ms";
std::stringstream ss; std::stringstream ss;
ss << std::fixed << std::setprecision(1) << ss << std::fixed << std::setprecision(1) <<
(ms.count()/1000.) << "s"; (ms.count()/1000.) << "s";
return ss.str(); return ss.str();
} }
@@ -243,8 +243,8 @@ void
reporter<_>:: reporter<_>::
on_case_begin(std::string const& name) on_case_begin(std::string const& name)
{ {
case_results_ = case_results (name); case_results_ = case_results(name);
if(!prefixed_) if(! prefixed_)
{ {
os_ << suite_results_.name << os_ << suite_results_.name <<
(case_results_.name.empty() ? "" : (case_results_.name.empty() ? "" :
@@ -278,7 +278,7 @@ on_fail(std::string const& reason)
++case_results_.total; ++case_results_.total;
os_ << os_ <<
"#" << case_results_.total << " failed" << "#" << case_results_.total << " failed" <<
(reason.empty() ? "" : ": ") << reason << std::endl; (reason.empty() ? "" : ": ") << reason << std::endl;
} }
template<class _> template<class _>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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