#include #include #include #include "JMath/JLimits.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" namespace { static const double A_MIN = -999.0; static const double A_MAX = +999.0; struct __A__ { /** * Constructor. * * \param a value */ __A__(double a) { this->a = a; } /** * Equals operator. * * \param first first value * \param second second value * \return true if first and second value are equal; else false */ friend inline bool operator==(const __A__& first, const __A__& second) { return first.a == second.a; } /** * Write object to output. * * \param out output stream * \param object object * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const __A__& object) { return out << object.a; } static __A__ min() { return __A__(A_MIN); } static __A__ max() { return __A__(A_MAX); } protected: double a; }; /** * Print class and zero value. * * \param out output stream * \param name class name */ template inline void print(std::ostream& out, const char* name) { using namespace std; using namespace JPP; out << setw(12) << left << name << ' ' << JLimits::min() << ' ' << JLimits::max() << endl; } #define PRINT(OUT, CLASS) print(OUT, #CLASS) } /** * \file * * Example program to test zero values (JMATH::zero). * \author mdejong */ int main(int argc, char**argv) { using namespace std; int debug; try { JParser<> zap("Example program to test zero values of non-primitive data types."); zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } using namespace JPP; PRINT(cout, size_t); PRINT(cout, int); PRINT(cout, float); PRINT(cout, double); PRINT(cout, long double); PRINT(cout, __A__); ASSERT(JLimits::min() == numeric_limits::min()); ASSERT(JLimits::max() == numeric_limits::max()); //ASSERT(JLimits::min() == numeric_limits::min()); ASSERT(JLimits::max() == numeric_limits::max()); ASSERT(JLimits<__A__> ::min() == A_MIN); ASSERT(JLimits<__A__> ::max() == A_MAX); return 0; }