mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
fix testspr trace implementation
This commit is contained in:
parent
e2de00d604
commit
7c31b83360
2 changed files with 30 additions and 7 deletions
|
@ -24,6 +24,28 @@
|
|||
#include <testspr/typeinfo.hpp>
|
||||
|
||||
namespace testspr {
|
||||
namespace detail {
|
||||
inline SPROUT_NON_CONSTEXPR std::ostream&
|
||||
to_string_impl(std::ostream& os) {
|
||||
return os;
|
||||
}
|
||||
template<typename Head, typename... Tail>
|
||||
inline SPROUT_NON_CONSTEXPR std::ostream&
|
||||
to_string_impl(std::ostream& os, Head const& head, Tail const&... tail) {
|
||||
return testspr::detail::to_string_impl(os << head, tail...);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// to_string
|
||||
//
|
||||
template<typename Head, typename... Tail>
|
||||
inline SPROUT_NON_CONSTEXPR std::string
|
||||
to_string(Head const& head, Tail const&... tail) {
|
||||
std::ostringstream os;
|
||||
testspr::detail::to_string_impl(os, head, tail...);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
//
|
||||
// print
|
||||
//
|
||||
|
@ -144,12 +166,13 @@ namespace testspr {
|
|||
template<typename T>
|
||||
inline SPROUT_NON_CONSTEXPR void
|
||||
print_hl(T const& t) {
|
||||
std::ostringstream oss;
|
||||
oss << t;
|
||||
std::string s(oss.str());
|
||||
for (std::string::size_type i = 0, last = 80 / s.size(); i != last; ++i) {
|
||||
std::string s(testspr::to_string(t));
|
||||
for (std::string::size_type i = 0, n = 80 / s.size(); i != n; ++i) {
|
||||
std::cout << s;
|
||||
}
|
||||
for (std::string::const_iterator it = s.begin(), last = s.begin() + 80 % s.size(); it != last; ++it) {
|
||||
std::cout << *it;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -488,12 +488,12 @@ namespace testspr {
|
|||
// TESTSPR_TRACE_BLOCK
|
||||
//
|
||||
# define TESTSPR_TRACE_BLOCK(name) \
|
||||
testspr::block_tracer SPROUT_PP_CAT(testspr_block_tracer_, __LINE__)(__FILE__, __LINE__, name)
|
||||
testspr::block_tracer SPROUT_PP_CAT(testspr_block_tracer_, __LINE__)(__FILE__, __LINE__, testspr::to_string(name))
|
||||
//
|
||||
// TESTSPR_TRACE_BLOCK_EXPR
|
||||
//
|
||||
# define TESTSPR_TRACE_BLOCK_EXPR(name) \
|
||||
((void)testspr::block_tracer(__FILE__, __LINE__, name))
|
||||
((void)testspr::block_tracer(__FILE__, __LINE__, testspr::to_string(name)))
|
||||
|
||||
namespace detail {
|
||||
inline SPROUT_NON_CONSTEXPR bool
|
||||
|
@ -545,7 +545,7 @@ namespace testspr {
|
|||
// TESTSPR_TRACE_MARK
|
||||
//
|
||||
# define TESTSPR_TRACE_MARK(name) \
|
||||
((void)testspr::trace_stack::instance().notify_mark(name, __FILE__, __LINE__))
|
||||
((void)testspr::trace_stack::instance().notify_mark(testspr::to_string(name), __FILE__, __LINE__))
|
||||
|
||||
//
|
||||
// TESTSPR_PRINT_TRACE_STACK
|
||||
|
|
Loading…
Reference in a new issue