Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Macros | Functions
JComparable.cc File Reference

Example program to test JLANG::JComparable class. More...

#include <iostream>
#include <iomanip>
#include "JLang/JComparable.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Macros

#define PRINT(OUT, OP, A, B)   OUT << "(" << A << ") " << #OP " (" << B << ") => " << (A OP B) << std::endl;
 Print. More...
 

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test JLANG::JComparable class.

Author
mdejong

Definition in file JComparable.cc.

Macro Definition Documentation

#define PRINT (   OUT,
  OP,
  A,
 
)    OUT << "(" << A << ") " << #OP " (" << B << ") => " << (A OP B) << std::endl;

Print.

Parameters
OUToutput stream
OPoperator
Afirst object
Bsecond object

Definition at line 74 of file JComparable.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 84 of file JComparable.cc.

85 {
86  using namespace std;
87  using namespace JPP;
88 
89  int debug;
90 
91  try {
92 
93  JParser<> zap("Example program to test comparisons of objects.");
94 
95  zap['d'] = make_field(debug) = 3;
96 
97  zap(argc, argv);
98  }
99  catch(const exception &error) {
100  FATAL(error.what() << endl);
101  }
102 
103 
104  __A__ a1(0);
105  __A__ a2(1);
106 
107  PRINT(cout, ==, a1, a2);
108  PRINT(cout, !=, a1, a2);
109  PRINT(cout, <, a1, a2);
110  PRINT(cout, <=, a1, a2);
111  PRINT(cout, >, a1, a2);
112  PRINT(cout, >=, a1, a2);
113 
114  __B__ b1(0);
115  __B__ b2(1);
116 
117  PRINT(cout, ==, b1, b1);
118  PRINT(cout, !=, b1, b2);
119  PRINT(cout, <, b1, b2);
120  PRINT(cout, <=, b1, b2);
121  PRINT(cout, >, b1, b2);
122  PRINT(cout, >=, b1, b2);
123 
124  PRINT(cout, ==, b1, 1);
125  PRINT(cout, !=, b1, 1);
126  PRINT(cout, <, b1, 1);
127  PRINT(cout, <=, b1, 1);
128  PRINT(cout, >, b1, 1);
129  PRINT(cout, >=, b1, 1);
130 
131  ASSERT(a1 == a1);
132  ASSERT(a1 != a2);
133  ASSERT(a1 < a2);
134  ASSERT(a1 <= a2);
135  ASSERT(! (a1 > a2));
136  ASSERT(! (a1 >= a2));
137 
138  ASSERT(b1 == b1);
139  ASSERT(b1 != b2);
140  ASSERT(b1 < b2);
141  ASSERT(b1 <= b2);
142  ASSERT(! (b1 > b2));
143  ASSERT(! (b1 >= b2));
144 
145  ASSERT(b1 == 0);
146  ASSERT(b1 != 1);
147  ASSERT(b1 < 1);
148  ASSERT(b1 <= 1);
149  ASSERT(! (b1 > 1));
150  ASSERT(! (b1 >= 1));
151 
152  return 0;
153 }
Utility class to parse command line options.
Definition: JParser.hh:1410
#define ASSERT(A)
Assert macro.
Definition: JMessage.hh:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
#define PRINT(OUT, OP, A, B)
Print.
Definition: JComparable.cc:74
int debug
debug level
Definition: JSirene.cc:59
#define FATAL(A)
Definition: JMessage.hh:65