Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
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)
 Print.
 

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

◆ PRINT

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

Print.

Parameters
OUToutput stream
OPoperator
Afirst object
Bsecond object

Definition at line 75 of file JComparable.cc.

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

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 85 of file JComparable.cc.

86{
87 using namespace std;
88 using namespace JPP;
89
90 int debug;
91
92 try {
93
94 JParser<> zap("Example program to test comparisons of objects.");
95
96 zap['d'] = make_field(debug) = 3;
97
98 zap(argc, argv);
99 }
100 catch(const exception &error) {
101 FATAL(error.what() << endl);
102 }
103
104
105 __A__ a1(0);
106 __A__ a2(1);
107
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 PRINT(cout, >=, a1, a2);
114
115 __B__ b1(0);
116 __B__ b2(1);
117
118 PRINT(cout, ==, b1, b1);
119 PRINT(cout, !=, b1, b2);
120 PRINT(cout, <, b1, b2);
121 PRINT(cout, <=, b1, b2);
122 PRINT(cout, >, b1, b2);
123 PRINT(cout, >=, b1, b2);
124
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 PRINT(cout, >=, b1, 1);
131
132 ASSERT(a1 == a1);
133 ASSERT(a1 != a2);
134 ASSERT(a1 < a2);
135 ASSERT(a1 <= a2);
136 ASSERT(! (a1 > a2));
137 ASSERT(! (a1 >= a2));
138
139 ASSERT(b1 == b1);
140 ASSERT(b1 != b2);
141 ASSERT(b1 < b2);
142 ASSERT(b1 <= b2);
143 ASSERT(! (b1 > b2));
144 ASSERT(! (b1 >= b2));
145
146 ASSERT(b1 == 0);
147 ASSERT(b1 != 1);
148 ASSERT(b1 < 1);
149 ASSERT(b1 <= 1);
150 ASSERT(! (b1 > 1));
151 ASSERT(! (b1 >= 1));
152
153 return 0;
154}
#define PRINT(OUT, OP, A, B)
Print.
#define ASSERT(A,...)
Assert macro.
Definition JMessage.hh:90
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).