}
catch (const libtest::fatal& e)
{
- stream::cerr(e.file(), e.line(), e.func()) << e.what();
_failed++;
formatter()->failed();
+ stream::make_cerr(e.file(), e.line(), e.func()) << e.what();
throw;
}
#include <algorithm>
#include <fstream>
#include <iostream>
-
+#include <ostream>
+
namespace libtest {
std::string& escape4XML(std::string const& arg, std::string& escaped_string)
void Formatter::skipped()
{
+ assert(current());
current()->result(TEST_SKIPPED);
- Out << name() << "."
- << current()->name()
- << "\t\t\t\t\t"
- << "[ " << test_strerror(current()->result()) << " ]";
+
+ Out
+ << "[ " << test_strerror(current()->result()) << " ]"
+ << "\t\t"
+ << name() << "." << current()->name()
+ ;
reset();
}
assert(current());
current()->result(TEST_FAILURE);
- Out << name()
- << "." << current()->name() << "\t\t\t\t\t"
- << "[ " << test_strerror(current()->result()) << " ]";
+ Out
+ << "[ " << test_strerror(current()->result()) << " ]"
+ << "\t\t"
+ << name() << "." << current()->name()
+ ;
reset();
}
{
assert(current());
current()->result(TEST_SUCCESS, timer_);
- std::string escaped_string;
- Out << name() << "."
- << current()->name()
- << "\t\t\t\t\t"
- << current()->timer()
- << " [ " << test_strerror(current()->result()) << " ]";
+ Out
+ << "[ " << test_strerror(current()->result()) << " ]"
+ << "\t"
+ << current()->timer()
+ << "\t"
+ << name() << "." << current()->name()
+ ;
reset();
}
assert(_suite_name.empty() == false);
TestCase* _current_testcase= new TestCase(arg);
_testcases.push_back(_current_testcase);
+
+ assert(current());
+
+ Echo
+ << "\t\t\t"
+ << name() << "." << current()->name()
+ << "... \r"
+ ;
}
void Formatter::reset()
}
};
+template<class Ch, class Tr, class A>
+ class channelfl {
+ private:
+
+ public:
+ typedef std::basic_ostringstream<Ch, Tr, A> stream_buffer;
+
+ public:
+ void operator()(const stream_buffer& s, std::ostream& _out,
+ const char* filename, int line_number, const char* func)
+ {
+ if (filename)
+ {
+ _out
+ << filename
+ << ":"
+ << line_number
+ << ": in "
+ << func << "() "
+ << s.str()
+ << std::flush;
+ }
+ else
+ {
+ _out
+ << s.str()
+ << std::flush;
+ }
+ }
+ };
+
template<template <class Ch, class Tr, class A> class OutputPolicy, class Ch = char, class Tr = std::char_traits<Ch>, class A = std::allocator<Ch> >
class log {
private:
const cout& operator=( const cout& );
};
+class cecho : public detail::log<detail::channelfl> {
+public:
+ cecho(const char* filename, int line_number, const char* func) :
+ detail::log<detail::channelfl>(std::cout, filename, line_number, func)
+ { }
+
+private:
+ cecho( const cecho& );
+ const cecho& operator=( const cecho& );
+};
} // namespace stream
#define Error stream::cerr(__FILE__, __LINE__, __func__)
+#define Echo stream::cecho(NULL, __LINE__, __func__)
+
#define Out stream::cout(NULL, __LINE__, __func__)
#define Outn() stream::cout(NULL, __LINE__, __func__) << " "