Files
boost_beast/include/beast/detail/unit_test/define_print.cpp
T

91 lines
1.7 KiB
C++
Raw Normal View History

2016-04-19 20:29:16 -04:00
//
// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
2016-04-19 20:29:16 -04:00
#include <beast/detail/unit_test/amount.hpp>
#include <beast/detail/unit_test/global_suites.hpp>
#include <beast/detail/unit_test/suite.hpp>
2014-10-28 06:56:19 -07:00
#include <string>
2014-03-20 17:25:39 -07:00
// Include this .cpp in your project to gain access to the printing suite
2014-03-07 20:06:12 -08:00
namespace beast {
2016-04-19 20:29:16 -04:00
namespace detail {
inline
2014-03-20 17:25:39 -07:00
namespace unit_test {
namespace detail {
/** A suite that prints the list of globally defined suites. */
class print_test : public suite
{
2014-10-28 06:56:19 -07:00
private:
template <class = void>
void
do_run();
2014-03-07 20:06:12 -08:00
public:
2014-10-28 06:56:19 -07:00
template <class = void>
2014-03-20 17:25:39 -07:00
static
std::string
2014-10-28 06:56:19 -07:00
prefix (suite_info const& s);
2014-03-07 20:06:12 -08:00
2014-10-28 06:56:19 -07:00
template <class = void>
2014-03-20 17:25:39 -07:00
void
2014-10-28 06:56:19 -07:00
print (suite_list &c);
2014-03-07 20:06:12 -08:00
2014-03-20 17:25:39 -07:00
void
run()
{
2014-10-28 06:56:19 -07:00
do_run();
2014-03-07 20:06:12 -08:00
}
};
2014-10-28 06:56:19 -07:00
template <class>
void
print_test::do_run()
{
log << "------------------------------------------";
print (global_suites());
log << "------------------------------------------";
pass();
}
template <class>
std::string
print_test::prefix (suite_info const& s)
{
if (s.manual())
return "|M| ";
return " ";
}
template <class>
void
print_test::print (suite_list &c)
{
std::size_t manual (0);
for (auto const& s : c)
{
log <<
prefix (s) <<
s.full_name();
if (s.manual())
++manual;
}
log <<
amount (c.size(), "suite") << " total, " <<
amount (manual, "manual suite")
;
}
2014-03-20 17:25:39 -07:00
BEAST_DEFINE_TESTSUITE_MANUAL(print,unit_test,beast);
2016-04-19 20:29:16 -04:00
} // detail
} // unit_test
} // detail
} // beast