28#include "dccl/logger.h"
30#include "../../common.h"
32bool same(
double a,
double b)
35 return std::abs(a - b) < 1e-10;
38template <
typename Int>
bool same(Int a, Int b) {
return a == b; }
40template <
typename T>
void check(T in,
int prec, T out)
42 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"Checking that " << in <<
" rounded to precision: " << prec <<
" is equal to "
44 assert(same(dccl::round(in, prec), out));
47int main(
int argc,
char* argv[])
50 for (
int i = 1; i < argc; ++i)
52 if (argv[i] && argv[i][0] ==
'-' && argv[i][1] ==
'v' && argv[i][2] ==
'\0')
56 dccl::dlog.
connect(verbose ? dccl::logger::ALL :
dccl::logger::WARN_PLUS, &std::cerr);
58 check(1.234, 2, 1.23);
62 check<int>(1239, -1, 1240);
63 check<int>(1351, -2, 1400);
64 check<int>(1450, -2, 1500);
65 check<int>(1344, -3, 1000);
67 check(1239.0, -1, 1240.0);
68 check(1351.0, -2, 1400.0);
69 check(1450.0, -2, 1500.0);
70 check(1344.0, -3, 1000.0);
72 check<int>(-499000, -3, -499000);
73 check<int>(-500000, -3, -500000);
75 check(-500000.0, -3, -500000.0);
83 check<dccl::int64>(1409165969804999ull, -3, 1409165969805000ull);
85 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"all tests passed" << std::endl;
bool is(logger::Verbosity verbosity, logger::Group group=logger::GENERAL)
Indicates the verbosity of the Logger until the next std::flush or std::endl. The boolean return is u...
void connect(int verbosity_mask, Slot slot)
Connect the output of one or more given verbosities to a slot (function pointer or similar)
Dynamic Compact Control Language namespace.