]> www.ginac.de Git - ginac.git/commitdiff
Clean up check suite a little bit.
authorRichard Kreckel <kreckel@ginac.de>
Mon, 3 Aug 2020 18:01:13 +0000 (20:01 +0200)
committerRichard Kreckel <kreckel@ginac.de>
Mon, 3 Aug 2020 18:15:27 +0000 (20:15 +0200)
Some tests in tiny test files are better moved elsewhere to reduce compile
and link time.

check/CMakeLists.txt
check/Makefile.am
check/check_mul_info.cpp [deleted file]
check/exam_factor.cpp
check/exam_paranoia.cpp
check/factor_univariate_bug.cpp [deleted file]

index 9d9e08390035b74efe6b60ee670e385eeef9dee1..bd6b76049540efac9837dccec8c203c871a0b001 100644 (file)
@@ -6,7 +6,6 @@ set(ginac_tests
        check_inifcns
        check_matrices
        check_lsolve
        check_inifcns
        check_matrices
        check_lsolve
-       check_mul_info
        heur_gcd_bug
        exam_paranoia
        exam_heur_gcd
        heur_gcd_bug
        exam_paranoia
        exam_heur_gcd
@@ -35,7 +34,6 @@ set(ginac_tests
        exam_cra
        exam_real_imag
        bugme_chinrem_gcd
        exam_cra
        exam_real_imag
        bugme_chinrem_gcd
-       factor_univariate_bug
        pgcd_relatively_prime_bug
        pgcd_infinite_loop)
 
        pgcd_relatively_prime_bug
        pgcd_infinite_loop)
 
index 8d00fdb1bedd3b133638a9649d36a61570f2ddf4..5f1d02e2590228aeeff29ae8327121667d8db178 100644 (file)
@@ -29,9 +29,7 @@ EXAMS = exam_paranoia \
        exam_structure  \
        exam_misc \
        exam_mod_gcd \
        exam_structure  \
        exam_misc \
        exam_mod_gcd \
-       check_mul_info \
        bugme_chinrem_gcd \
        bugme_chinrem_gcd \
-       factor_univariate_bug \
        pgcd_relatively_prime_bug \
        pgcd_infinite_loop \
        exam_cra \
        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_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
 
 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
 
 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
 
 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 (file)
index 34652f8..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "ginac.h"
-#include <iostream>
-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;
-}
index c848fdd4ebc2ca6f9a29cd717366535dad2a1730..d346efed3e07c82dce355eb63d7d0b6db440487a 100644 (file)
@@ -43,7 +43,10 @@ static unsigned exam_factor1()
        ex e;
        symbol x("x");
        lst syms = {x};
        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);
 
        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;
 }
 
        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,
 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;
 }
 
        return result;
 }
 
-static unsigned check_factorization(const exvector& factors)
-{
-       ex e = dynallocate<mul>(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;
 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_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 += exam_factor_wang(); cout << '.' << flush;
-       result += factor_integer_content_bug();
-       cout << '.' << flush;
 
        return result;
 }
 
        return result;
 }
index 7a64e52cc1ab28acdcbc929ffd3d3a66174b365d..7977bd2e88f5440990f2c4b389237f726a0cb1f3 100644 (file)
@@ -504,6 +504,17 @@ static unsigned exam_paranoia20()
        return result;
 }
 
        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;
 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_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;
        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 (file)
index 80a7ce4..0000000
+++ /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 <iostream>
-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;
-}