8#ifndef SRC_APPS_CHEM_TEST_UTILITIES_H_
9#define SRC_APPS_CHEM_TEST_UTILITIES_H_
18 logger << std::scientific << std::setprecision(8) ;
25 int ncharacter=line.size();
26 if (line.size()<
size_t(
length)) line+= std::string(
length-ncharacter,
' ' );
36 std::cout <<
logger.str() << std::endl;
41 std::string message,
double time=-1.0) {
44 bool success=
error<tol;
58 void checkpoint(
double value,
double reference,
double tol,
59 std::string message,
double time=-1.0) {
62 double error=fabs(value-reference);
63 bool success=
error<tol;
77 void checkpoint(
bool success, std::string message,
double time=-1.0) {
95 if (success) os <<
"\033[32m" <<
"passed " <<
"\033[0m";
96 else os <<
"\033[31m" <<
"failed " <<
"\033[0m";
99 ss<<
" in " << std::fixed << std::setprecision(1) << time <<
"s";
106 int end(
bool success=
true) {
113 return (success) ? 0 : 1;
120 std::streambuf* stream_buffer_file =
logger.rdbuf();
121 std::cout.rdbuf(stream_buffer_file);
131 if (newline) std::cout << std::endl;
static const double length
Definition hedft.cc:48
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
static double cpu_time()
Returns the cpu time in seconds relative to an arbitrary origin.
Definition timers.h:127
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:225
void error(const char *msg)
Definition world.cc:139
small class for pretty printing of test output
Definition test_utilities.h:15
double time_last_checkpoint
Definition test_utilities.h:143
int end(bool success=true)
Definition test_utilities.h:106
void checkpoint(double value, double reference, double tol, std::string message, double time=-1.0)
Definition test_utilities.h:58
double time_begin
Definition test_utilities.h:142
static std::string ltrim_to_length(std::string line, long length=70)
Definition test_utilities.h:24
void checkpoint(bool success, std::string message, double time=-1.0)
Definition test_utilities.h:77
std::stringstream logger
Definition test_utilities.h:134
void set_cout_to_terminal(bool newline=true)
newline for use by user, not for internal use (e.g. checkpoint())
Definition test_utilities.h:125
test_output(std::string line)
Definition test_utilities.h:16
~test_output()
Definition test_utilities.h:30
bool get_final_success() const
Definition test_utilities.h:135
std::streambuf * stream_buffer_cout
Definition test_utilities.h:141
void print_and_clear_log()
Definition test_utilities.h:34
void checkpoint(double error, double tol, std::string message, double time=-1.0)
Definition test_utilities.h:40
bool have_checkpoints
Definition test_utilities.h:140
void print_success_fail(std::ostream &os, bool success, double time, double error)
Definition test_utilities.h:93
bool cout_set_to_logger
Definition test_utilities.h:139
bool final_success
Definition test_utilities.h:138
void set_cout_to_logger()
Definition test_utilities.h:116