/** @file exam_numeric.cpp
*
- * These exams creates some numbers and check the result of several boolean
+ * These exams creates some numbers and check the result of several Boolean
* tests on these numbers like is_integer() etc... */
/*
- * GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2020 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "exams.h"
+#include "ginac.h"
+using namespace GiNaC;
+#include <iostream>
#include <sstream>
+using namespace std;
/* Simple and maybe somewhat pointless consistency tests of assorted tests and
* conversions. */
-static unsigned exam_numeric1(void)
+static unsigned exam_numeric1()
{
unsigned result = 0;
numeric test_int1(42);
<< " erroneously not recognized as complex rational" << endl;
++result;
}
+ if (test_crat.info(info_flags::nonnegative)) {
+ clog << test_crat
+ << " erroneously recognized as non-negative number" << endl;
+ ++result;
+ }
int i = numeric(1984).to_int();
if (i-1984) {
* Implementing a workaround sadly introduced another bug on May 28th 1999
* that was fixed on May 31st. The workaround turned out to be stupid and
* the original bug in CLN was finally killed on September 2nd. */
-static unsigned exam_numeric2(void)
+static unsigned exam_numeric2()
{
unsigned result = 0;
/* Assorted tests to ensure some crucial functions behave exactly as specified
* in the documentation. */
-static unsigned exam_numeric3(void)
+static unsigned exam_numeric3()
{
unsigned result = 0;
numeric calc_rem, calc_quo;
/* Now we perform some less trivial checks about several functions which should
* return exact numbers if possible. */
-static unsigned exam_numeric4(void)
+static unsigned exam_numeric4()
{
unsigned result = 0;
bool passed;
/* This test examines that simplifications of the form 5^(3/2) -> 5*5^(1/2)
* are carried out properly. */
-static unsigned exam_numeric5(void)
+static unsigned exam_numeric5()
{
unsigned result = 0;
/* This test checks whether the numeric output/parsing routines are
consistent. */
-static unsigned exam_numeric6(void)
+static unsigned exam_numeric6()
{
unsigned result = 0;
// Read back expression from string
string x_as_string = s.str();
- ex x_again(x_as_string, lst(sym));
+ ex x_again(x_as_string, lst{sym});
// They should be equal
if (!x_again.is_equal(x)) {
return result;
}
-unsigned exam_numeric(void)
+unsigned exam_numeric()
{
unsigned result = 0;
cout << "examining consistency of numeric types" << flush;
- clog << "----------consistency of numeric types:" << endl;
result += exam_numeric1(); cout << '.' << flush;
result += exam_numeric2(); cout << '.' << flush;
result += exam_numeric5(); cout << '.' << flush;
result += exam_numeric6(); cout << '.' << flush;
- if (!result) {
- cout << " passed " << endl;
- clog << "(no output)" << endl;
- } else {
- cout << " failed " << endl;
- }
-
return result;
}
+
+int main(int argc, char** argv)
+{
+ return exam_numeric();
+}