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,
' ' );
37 std::cout <<
logger.str() << std::endl;
42 std::string message,
double time=-1.0) {
45 bool success=
error<tol;
59 void checkpoint(
double value,
double reference,
double tol,
60 std::string message,
double time=-1.0) {
63 double error=fabs(value-reference);
64 bool success=
error<tol;
78 void checkpoint(
bool success, std::string message,
double time=-1.0) {
96 if (success) os <<
"\033[32m" <<
"passed " <<
"\033[0m";
97 else os <<
"\033[31m" <<
"failed " <<
"\033[0m";
100 ss<<
" in " << std::fixed << std::setprecision(1) << time <<
"s";
107 int end(
bool success=
true) {
114 return (success) ? 0 : 1;
121 std::streambuf* stream_buffer_file =
logger.rdbuf();
122 std::cout.rdbuf(stream_buffer_file);
132 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:144
int end(bool success=true)
Definition test_utilities.h:107
void checkpoint(double value, double reference, double tol, std::string message, double time=-1.0)
Definition test_utilities.h:59
double time_begin
Definition test_utilities.h:143
static std::string ltrim_to_length(std::string line, long length=70)
Definition test_utilities.h:25
void checkpoint(bool success, std::string message, double time=-1.0)
Definition test_utilities.h:78
std::stringstream logger
Definition test_utilities.h:135
void set_cout_to_terminal(bool newline=true)
newline for use by user, not for internal use (e.g. checkpoint())
Definition test_utilities.h:126
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:136
std::streambuf * stream_buffer_cout
Definition test_utilities.h:142
void print_and_clear_log()
Definition test_utilities.h:35
void checkpoint(double error, double tol, std::string message, double time=-1.0)
Definition test_utilities.h:41
bool have_checkpoints
Definition test_utilities.h:141
void print_success_fail(std::ostream &os, bool success, double time, double error)
Definition test_utilities.h:94
bool cout_set_to_logger
Definition test_utilities.h:140
bool final_success
Definition test_utilities.h:139
void set_cout_to_logger()
Definition test_utilities.h:117