1 /** @file exam_relational.cpp
3 * Small test for the relational objects and their conversion to bool. */
6 * GiNaC Copyright (C) 1999-2021 Johannes Gutenberg University Mainz, Germany
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 using namespace GiNaC;
29 // Elementary relations should fall back to numeric comparisons.
30 static unsigned exam_relational_elementary()
36 clog << "'" << one << " == " << two << "' was converted to true." << endl;
40 clog << "'" << one << " != " << two << "' was not converted to true." << endl;
44 clog << "'" << one << " < " << two << "' was not converted to true." << endl;
48 clog << "'" << one << " <= " << two << "' was not converted to true." << endl;
52 clog << "'" << one << " > " << two << "' was converted to true." << endl;
56 clog << "'" << one << " >= " << two << "' was converted to true." << endl;
63 // These should fall back to looking up info flags.
64 static unsigned exam_relational_possymbol()
70 clog << "for positive p, 'p == 0' was converted to true." << endl;
74 clog << "for positive p, 'p != 0' was not converted to true." << endl;
78 clog << "for positive p, 'p < 0' was converted to true." << endl;
82 clog << "for positive p, 'p <= 0' was converted to true." << endl;
86 clog << "for positive p, 'p > 0' was not converted to true." << endl;
90 clog << "for positive p, 'p >= 0' was not converted to true." << endl;
97 // Very simple arithmetic should be supported, too.
98 static unsigned exam_relational_arith()
103 if (!(p + 2 > p + 1)) {
104 clog << "for positive p, 'p + 2 > p + 1' was not converted to true." << endl;
108 clog << "for positive p, 'p > -p' was not converted to true." << endl;
112 clog << "for positive p, '2*p > p' was not converted to true." << endl;
119 unsigned exam_relational()
123 cout << "examining relational objects" << flush;
125 result += exam_relational_elementary(); cout << '.' << flush;
126 result += exam_relational_possymbol(); cout << '.' << flush;
127 result += exam_relational_arith(); cout << '.' << flush;
132 int main(int argc, char** argv)
134 return exam_relational();