]> www.ginac.de Git - ginac.git/blob - check/check_is_polynomial.cpp
a62f0c2680f31b623682d711a32cbc4024448cac
[ginac.git] / check / check_is_polynomial.cpp
1 /*
2  * Check for inconsistency in power::is_polynomial
3  */
4 #include "ginac.h"
5 #include <iostream>
6 #include <stdexcept>
7 using namespace std;
8 using namespace GiNaC;
9
10 static void do_test(const ex& e, const ex& s)
11 {
12         if (e.is_polynomial(s))
13                 return;
14         cerr << "*** Error: is_polynomial() says \"" << e << "\""
15                 << "is not a polynomial in \"" << s << "\"" << endl;
16         throw std::logic_error("bug in is_polynomial()");
17 }
18
19 int main(int argc, char** argv)
20 {
21         cout << "checking for bugs in is_polynomial()... " << flush;
22         symbol x("x"), s("s");
23         ex e = sin(x) + 2*s;
24         ex g = pow(2, x) + 2*s;
25         do_test(e, s);
26         do_test(g, s);
27         cout << " OK, not found." << endl;
28         return 0;
29 }
30