#include #include #include #include "JTools/JTuple.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to test JTOOLS::JTuple class. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; int debug; try { JParser<> zap("Example program to test tuple class."); zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } { typedef JTYPELIST::typelist typelist; JTuple A(+1, +2, +0.9999); JTuple B(-A); DEBUG(A.first << endl); DEBUG(A.second.first << endl); DEBUG(A.second.second << endl); DEBUG("A = " << showpos << A << endl); DEBUG("B = " << showpos << B << endl); DEBUG("A + B = " << noshowpos << A+B << endl); ASSERT(A == A, "A == A"); ASSERT(A != B, "A != B"); } { typedef JTYPELIST::typelist typelist; JTuple A; JTuple B; A.first = "aap"; A.second = 1234; B.first = "noot"; B.second = -A.second; JTuple C = A + B; DEBUG("A = " << A << endl); DEBUG("B = " << B << endl); DEBUG("A + B = " << C << endl); // uses std::string operator::+=() ASSERT(C == JTuple("aapnoot", 0), "Test of A + B with std::string"); } { ostringstream os; os << JPP::make_tuple(1, string("aap"), 0.99); DEBUG(os.str() << endl); ASSERT(os.str() == "1 aap 0.99", "Test of JPP::make_tuple"); } return 0; }