8#ifndef SRC_APPS_CHEM_TEST_UTILITIES_H_
9#define SRC_APPS_CHEM_TEST_UTILITIES_H_
19 logger << std::scientific << std::setprecision(8) ;
26 int ncharacter=line.size();
27 if (line.size()<
size_t(
length)) line+= std::string(
length-ncharacter,
' ' );
41 std::cout <<
logger.str() << std::endl;
46 std::string message,
double time=-1.0) {
49 bool success=
error<tol;
63 void checkpoint(
double value,
double reference,
double tol,
64 std::string message,
double time=-1.0) {
67 double error=fabs(value-reference);
68 bool success=
error<tol;
82 void checkpoint(
bool success, std::string message,
double time=-1.0) {
101 if (success) os <<
"\033[32m" <<
"passed " <<
"\033[0m";
102 else os <<
"\033[31m" <<
"failed " <<
"\033[0m";
104 std::stringstream ss;
105 ss<<
" in " << std::fixed << std::setprecision(1) << time <<
"s";
113 int end(
bool success=
true) {
120 return (success) ? 0 : 1;
127 std::streambuf* stream_buffer_file =
logger.rdbuf();
128 std::cout.rdbuf(stream_buffer_file);
138 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:226
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:150
int end(bool success=true)
Definition test_utilities.h:113
void checkpoint(double value, double reference, double tol, std::string message, double time=-1.0)
Definition test_utilities.h:63
double time_begin
Definition test_utilities.h:149
static std::string ltrim_to_length(std::string line, long length=70)
Definition test_utilities.h:25
bool do_print
Definition test_utilities.h:151
void checkpoint(bool success, std::string message, double time=-1.0)
Definition test_utilities.h:82
std::stringstream logger
Definition test_utilities.h:141
void set_cout_to_terminal(bool newline=true)
newline for use by user, not for internal use (e.g. checkpoint())
Definition test_utilities.h:132
test_output(std::string line, bool print=true)
Definition test_utilities.h:17
~test_output()
Definition test_utilities.h:31
bool get_final_success() const
Definition test_utilities.h:142
std::streambuf * stream_buffer_cout
Definition test_utilities.h:148
void print_and_clear_log()
Definition test_utilities.h:39
void checkpoint(double error, double tol, std::string message, double time=-1.0)
Definition test_utilities.h:45
bool have_checkpoints
Definition test_utilities.h:147
void print_success_fail(std::ostream &os, bool success, double time, double error) const
Definition test_utilities.h:98
bool cout_set_to_logger
Definition test_utilities.h:146
bool final_success
Definition test_utilities.h:145
void set_cout_to_logger()
Definition test_utilities.h:123
void set_do_print(bool print)
Definition test_utilities.h:35