X-Git-Url: https://ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=check%2Fexam_numeric.cpp;h=3b943b17e41f359381fd26575c74a3ea5bb15ef9;hb=fc15782d51037f2432129a153c47b7d7697c129b;hp=fd1bf872c3296f41f5686af4c5355032d6ed68bd;hpb=383d5eb3b0f0506810d9105a268f939125bfc347;p=ginac.git diff --git a/check/exam_numeric.cpp b/check/exam_numeric.cpp index fd1bf872..3b943b17 100644 --- a/check/exam_numeric.cpp +++ b/check/exam_numeric.cpp @@ -4,7 +4,7 @@ * tests on these numbers like is_integer() etc... */ /* - * GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2003 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 @@ -23,6 +23,8 @@ #include "exams.h" +#include + /* Simple and maybe somewhat pointless consistency tests of assorted tests and * conversions. */ static unsigned exam_numeric1(void) @@ -79,7 +81,7 @@ static unsigned exam_numeric1(void) } e2 = test_int1 + a; - if (ex_to_numeric(e2).is_integer()) { + if (e2.info(info_flags::integer)) { clog << "expression " << e2 << " erroneously recognized as integer" << endl; ++result; @@ -315,6 +317,62 @@ static unsigned exam_numeric5(void) return result; } +/* This test checks whether the numeric output/parsing routines are + consistent. */ +static unsigned exam_numeric6(void) +{ + unsigned result = 0; + + symbol sym("sym"); + vector test_numbers; + test_numbers.push_back(numeric(0)); // zero + test_numbers.push_back(numeric(1)); // one + test_numbers.push_back(numeric(-1)); // minus one + test_numbers.push_back(numeric(42)); // positive integer + test_numbers.push_back(numeric(-42)); // negative integer + test_numbers.push_back(numeric(14,3)); // positive rational + test_numbers.push_back(numeric(-14,3)); // negative rational + test_numbers.push_back(numeric(3.141)); // positive decimal + test_numbers.push_back(numeric(-3.141)); // negative decimal + test_numbers.push_back(numeric(0.1974)); // positive decimal, leading zero + test_numbers.push_back(numeric(-0.1974)); // negative decimal, leading zero + test_numbers.push_back(sym); // symbol + + for (vector::const_iterator br=test_numbers.begin(); br::const_iterator bi=test_numbers.begin(); bi::const_iterator er=test_numbers.begin(); er::const_iterator ei=test_numbers.begin(); ei