From 3563317bdfee90677c041bf1cb585ad220e9b7d3 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Mon, 3 Aug 2020 20:01:13 +0200 Subject: [PATCH] Clean up check suite a little bit. Some tests in tiny test files are better moved elsewhere to reduce compile and link time. --- check/CMakeLists.txt | 2 -- check/Makefile.am | 8 ----- check/check_mul_info.cpp | 14 --------- check/exam_factor.cpp | 52 ++++++++++++++------------------- check/exam_paranoia.cpp | 12 ++++++++ check/factor_univariate_bug.cpp | 21 ------------- 6 files changed, 34 insertions(+), 75 deletions(-) delete mode 100644 check/check_mul_info.cpp delete mode 100644 check/factor_univariate_bug.cpp diff --git a/check/CMakeLists.txt b/check/CMakeLists.txt index 9d9e0839..bd6b7604 100644 --- a/check/CMakeLists.txt +++ b/check/CMakeLists.txt @@ -6,7 +6,6 @@ set(ginac_tests check_inifcns check_matrices check_lsolve - check_mul_info heur_gcd_bug exam_paranoia exam_heur_gcd @@ -35,7 +34,6 @@ set(ginac_tests exam_cra exam_real_imag bugme_chinrem_gcd - factor_univariate_bug pgcd_relatively_prime_bug pgcd_infinite_loop) diff --git a/check/Makefile.am b/check/Makefile.am index 8d00fdb1..5f1d02e2 100644 --- a/check/Makefile.am +++ b/check/Makefile.am @@ -29,9 +29,7 @@ EXAMS = exam_paranoia \ exam_structure \ exam_misc \ exam_mod_gcd \ - check_mul_info \ bugme_chinrem_gcd \ - factor_univariate_bug \ pgcd_relatively_prime_bug \ pgcd_infinite_loop \ exam_cra \ @@ -78,9 +76,6 @@ check_matrices_LDADD = ../ginac/libginac.la check_lsolve_SOURCES = check_lsolve.cpp genex.cpp check_lsolve_LDADD = ../ginac/libginac.la -check_mul_info_SOURCES = check_mul_info.cpp -check_mul_info_LDADD = ../ginac/libginac.la - exam_paranoia_SOURCES = exam_paranoia.cpp exam_paranoia_LDADD = ../ginac/libginac.la @@ -262,9 +257,6 @@ time_parser_LDADD = ../ginac/libginac.la bugme_chinrem_gcd_SOURCES = bugme_chinrem_gcd.cpp bugme_chinrem_gcd_LDADD = ../ginac/libginac.la -factor_univariate_bug_SOURCES = factor_univariate_bug.cpp -factor_univariate_bug_LDADD = ../ginac/libginac.la - pgcd_relatively_prime_bug_SOURCES = pgcd_relatively_prime_bug.cpp pgcd_relatively_prime_bug_LDADD = ../ginac/libginac.la diff --git a/check/check_mul_info.cpp b/check/check_mul_info.cpp deleted file mode 100644 index 34652f8d..00000000 --- a/check/check_mul_info.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "ginac.h" -#include -using namespace GiNaC; - -int main(int argc, char** argv) -{ - symbol x("x"), y("y"); - ex e = x*y; - if (!e.info(info_flags::indefinite)) { - std::cerr << "eek, product of two symbols is NOT indefinite"; - return 1; - } - return 0; -} diff --git a/check/exam_factor.cpp b/check/exam_factor.cpp index c848fdd4..d346efed 100644 --- a/check/exam_factor.cpp +++ b/check/exam_factor.cpp @@ -43,7 +43,10 @@ static unsigned exam_factor1() ex e; symbol x("x"); lst syms = {x}; - + + e = 1; + result += check_factor(e); + e = ex("1+x-x^3", syms); result += check_factor(e); @@ -190,6 +193,23 @@ static unsigned check_factor_expanded(const ex& e) return 0; } +static unsigned exam_factor_content() +{ + unsigned result = 0; + ex e; + symbol x("x"), y("y"); + + // Fixed 2013-07-28 by Alexei Sheplyakov in factor_univariate(). + e = ex("174247781*x^2-1989199947807987/200000000000000", lst{x}); + result += check_factor(e); + + // Fixed 2014-05-18 by Alexei Sheplyakov in factor_multivariate(). + e = ex("(x+y+x*y)*(3*x+2*y)", lst{x, y}); + result += check_factor(e); + + return result; +} + static unsigned exam_factor_wang() { // these 15 polynomials are from the appendix of P.S.Wang, @@ -260,33 +280,6 @@ static unsigned exam_factor_wang() return result; } -static unsigned check_factorization(const exvector& factors) -{ - ex e = dynallocate(factors); - ex ef = factor(e.expand()); - if (ef.nops() != factors.size()) { - clog << "wrong number of factors, expected " << factors.size() << - ", got " << ef.nops(); - return 1; - } - for (size_t i = 0; i < ef.nops(); ++i) { - if (find(factors.begin(), factors.end(), ef.op(i)) == factors.end()) { - clog << "wrong factorization: term not found: " << ef.op(i); - return 1; - } - } - return 0; -} - -static unsigned factor_integer_content_bug() -{ - parser reader; - exvector factors; - factors.push_back(reader("x+y+x*y")); - factors.push_back(reader("3*x+2*y")); - return check_factorization(factors); -} - unsigned exam_factor() { unsigned result = 0; @@ -296,9 +289,8 @@ unsigned exam_factor() result += exam_factor1(); cout << '.' << flush; result += exam_factor2(); cout << '.' << flush; result += exam_factor3(); cout << '.' << flush; + result += exam_factor_content(); cout << '.' << flush; result += exam_factor_wang(); cout << '.' << flush; - result += factor_integer_content_bug(); - cout << '.' << flush; return result; } diff --git a/check/exam_paranoia.cpp b/check/exam_paranoia.cpp index 7a64e52c..7977bd2e 100644 --- a/check/exam_paranoia.cpp +++ b/check/exam_paranoia.cpp @@ -504,6 +504,17 @@ static unsigned exam_paranoia20() return result; } +static unsigned exam_mul_info() +{ + symbol x("x"), y("y"); + ex e = x*y; + if (!e.info(info_flags::indefinite)) { + clog << "eek, product of two symbols is NOT indefinite\n"; + return 1; + } + return 0; +} + static unsigned is_polynomial_false_positive() { unsigned result = 0; @@ -699,6 +710,7 @@ unsigned exam_paranoia() result += exam_paranoia18(); cout << '.' << flush; result += exam_paranoia19(); cout << '.' << flush; result += exam_paranoia20(); cout << '.' << flush; + result += exam_mul_info(); cout << '.' << flush; result += is_polynomial_false_positive(); cout << '.' << flush; result += exam_paranoia21(); cout << '.' << flush; result += exam_paranoia22(); cout << '.' << flush; diff --git a/check/factor_univariate_bug.cpp b/check/factor_univariate_bug.cpp deleted file mode 100644 index 80a7ce4c..00000000 --- a/check/factor_univariate_bug.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @file factor_upoly_q_bug.cpp Check for a bug in factor_univariate(). - * - * factor_univariate() didn't check if the argument is an integer polynomial, - * the result was a segfault. - */ -#include "ginac.h" -#include -using namespace GiNaC; -using namespace std; - -int main(int argc, char** argv) -{ - cout << "checking if factor() handles rational polynomials. "; - parser p; - ex e = p("174247781*x^2-1989199947807987/200000000000000*x"); - ex ef = factor(e); - ex diff = (e - ef).expand(); - cout << "yes" << endl; - return 0; -} -- 2.44.0