Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
#ifndef TESTS_COMMON_H
#define TESTS_COMMON_H
#include <iostream>
#include <fstream>
#include <string.h>
#include "cxxtest/TestSuite.h"
#include "cxxtest/GlobalFixture.h"
#include "misc/auxiliary.h"
#include "coeffs/coeffs.h"
#include "coeffs/numbers.h"
#include "reporter/reporter.h"
#include "resources/feResource.h"
#ifndef PLURAL_INTERNAL_DECLARATIONS
#define PLURAL_INTERNAL_DECLARATIONS
#endif
#include "polys/nc/gb_hack.h"
// #pragma GCC diagnostic ignored "-Wwrite-strings"
namespace
{
static inline std::ostream& operator<< (std::ostream& o, const n_coeffType& type)
{
#define CASE(A) case A: return o << (" " # A) << " ";
switch( type )
{
CASE(n_unknown);
CASE(n_Zp);
CASE(n_Q);
CASE(n_R);
CASE(n_GF);
CASE(n_long_R);
CASE(n_algExt);
CASE(n_transExt);
CASE(n_long_C);
CASE(n_Z);
CASE(n_Zn);
CASE(n_Znm);
CASE(n_Z2m);
CASE(n_CF);
default: return o << "Unknown type: [" << (unsigned long) type << "]";
}
#undef CASE
return o;
}
template<typename T>
static inline std::string _2S(T i)
{
std::stringstream ss;
ss << i;
// std::string s = ss.str();
return ss.str();
}
static inline std::string _2S(number a, const coeffs r)
{
n_Test(a,r);
StringSetS("");
n_Write(a, r);
std::stringstream ss;
{
char* s = StringEndS(); ss << s; omFree(s);
}
return ss.str();
}
static inline void PrintSized(/*const*/ number a, const coeffs r, BOOLEAN eoln = TRUE)
{
std::clog << _2S(a, r) << ", of size: " << n_Size(a, r);
if( eoln )
std::clog << std::endl;
}
}
class GlobalPrintingFixture : public CxxTest::GlobalFixture
{
std::ofstream _ofs;
bool _redirect;
public:
GlobalPrintingFixture(bool redirect = false): _redirect(redirect){}
~GlobalPrintingFixture()
{
if( _ofs)
_ofs.close();
}
void Redirect()
{
const int ll = strlen(argv0);
const int l = 5 + ll;
char* s = (char *)omAlloc0(l);
s = strncpy(s, argv0, ll);
strncpy(s + ll, ".log", 5);
_ofs.open(s); // , ios_base::out)
omFreeSize((ADDRESS)s, l);
std::clog.rdbuf(_ofs.rdbuf());
}
virtual bool setUpWorld()
{
if( _redirect )
Redirect();
std::clog << std::endl << ( "<world>" ) << std::endl << std::endl;
feInitResources(argv0);
StringSetS("resources in use (as reported by feStringAppendResources(0):\n");
feStringAppendResources(0);
{ char* s = StringEndS(); PrintS(s); omFree(s); }
return true;
}
virtual bool tearDownWorld()
{
std::clog << std::endl << std::endl <<( "</world>" ) << std::endl << std::endl ;
return true;
}
virtual bool setUp() { std::clog << std::endl << std::endl <<( "<test>" ) << std::endl << std::endl; return true; }
virtual bool tearDown() { std::clog << std::endl << std::endl <<( "</test>" ) << std::endl << std::endl; return true; }
};
template void CxxTest::doAssertDiffers<n_Procs_s*, void*>(char const*, unsigned int, char const*, n_Procs_s*, char const*, void*, char const*);
template void CxxTest::doAssertDiffers<snumber* (*)(long, n_Procs_s*), void*>(char const*, unsigned int, char const*, snumber* (*)(long, n_Procs_s*), char const*, void*, char const*);
template void CxxTest::doAssertDiffers<snumber* (*)(snumber*, snumber*, n_Procs_s*), void*>(char const*, unsigned int, char const*, snumber* (*)(snumber*, snumber*, n_Procs_s*), char const*, void*, char const*);
template void CxxTest::doAssertDiffers<void (*)(n_Procs_s*, int), void*>(char const*, unsigned int, char const*, void (*)(n_Procs_s*, int), char const*, void*, char const*);
template void CxxTest::doAssertDiffers<void (*)(snumber**, n_Procs_s*), void*>(char const*, unsigned int, char const*, void (*)(snumber**, n_Procs_s*), char const*, void*, char const*);
template void CxxTest::doAssertDiffers<void (*)(snumber*&, n_Procs_s*), void*>(char const*, unsigned int, char const*, void (*)(snumber*&, n_Procs_s*), char const*, void*, char const*);
template void CxxTest::doAssertEquals<int, int>(char const*, unsigned int, char const*, int, char const*, int, char const*);
template void CxxTest::doAssertEquals<n_coeffType, n_coeffType>(char const*, unsigned int, char const*, n_coeffType, char const*, n_coeffType, char const*);
template void CxxTest::doAssertEquals<snumber* (*)(long, n_Procs_s*), snumber* (*)(long, n_Procs_s*)>(char const*, unsigned int, char const*, snumber* (*)(long, n_Procs_s*), char const*, snumber* (*)(long, n_Procs_s*), char const*);
template void CxxTest::doAssertEquals<snumber* (*)(snumber*, snumber*, n_Procs_s*), snumber* (*)(snumber*, snumber*, n_Procs_s*)>(char const*, unsigned int, char const*, snumber* (*)(snumber*, snumber*, n_Procs_s*), char const*, snumber* (*)(snumber*, snumber*, n_Procs_s*), char const*);
template void CxxTest::doAssertEquals<void (*)(snumber**, n_Procs_s*), void (*)(snumber**, n_Procs_s*)>(char const*, unsigned int, char const*, void (*)(snumber**, n_Procs_s*), char const*, void (*)(snumber**, n_Procs_s*), char const*);
template bool CxxTest::differs<n_Procs_s*, void*>(n_Procs_s*, void*);
template bool CxxTest::differs<snumber* (*)(long, n_Procs_s*), void*>(snumber* (*)(long, n_Procs_s*), void*);
template bool CxxTest::differs<snumber* (*)(snumber*, snumber*, n_Procs_s*), void*>(snumber* (*)(snumber*, snumber*, n_Procs_s*), void*);
template bool CxxTest::differs<void (*)(n_Procs_s*, int), void*>(void (*)(n_Procs_s*, int), void*);
template bool CxxTest::differs<void (*)(snumber**, n_Procs_s*), void*>(void (*)(snumber**, n_Procs_s*), void*);
template bool CxxTest::differs<void (*)(snumber*&, n_Procs_s*), void*>(void (*)(snumber*&, n_Procs_s*), void*);
template bool CxxTest::equals<int, int>(int, int);
template bool CxxTest::equals<n_coeffType, n_coeffType>(n_coeffType, n_coeffType);
template bool CxxTest::equals<snumber* (*)(long, n_Procs_s*), snumber* (*)(long, n_Procs_s*)>(snumber* (*)(long, n_Procs_s*), snumber* (*)(long, n_Procs_s*));
template bool CxxTest::equals<snumber* (*)(snumber*, snumber*, n_Procs_s*), snumber* (*)(snumber*, snumber*, n_Procs_s*)>(snumber* (*)(snumber*, snumber*, n_Procs_s*), snumber* (*)(snumber*, snumber*, n_Procs_s*));
template bool CxxTest::equals<void (*)(snumber**, n_Procs_s*), void (*)(snumber**, n_Procs_s*)>(void (*)(snumber**, n_Procs_s*), void (*)(snumber**, n_Procs_s*));
template char* CxxTest::numberToString<long>(long, char*, long, unsigned int, unsigned int);
template void CxxTest::doAssertDiffers<ip_sring*, void*>(char const*, unsigned int, char const*, ip_sring*, char const*, void*, char const*);
template void CxxTest::doAssertEquals<short, int>(char const*, unsigned int, char const*, short, char const*, int, char const*);
template bool CxxTest::differs<ip_sring*, void*>(ip_sring*, void*);
template bool CxxTest::equals<short, int>(short, int);
#endif /* TESTS_COMMON_H */
GlobalFixture.h
TestSuite.h
auxiliary.h
All the auxiliary stuff.
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
TRUE
#define TRUE
Definition auxiliary.h:101
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
l
int l
Definition cfEzgcd.cc:100
i
int i
Definition cfEzgcd.cc:132
CxxTest::GlobalFixture
Definition GlobalFixture.h:9
GlobalPrintingFixture::GlobalPrintingFixture
GlobalPrintingFixture(bool redirect=false)
Definition common.h:95
GlobalPrintingFixture::Redirect
void Redirect()
Definition common.h:103
GlobalPrintingFixture::tearDown
virtual bool tearDown()
Definition common.h:138
GlobalPrintingFixture::tearDownWorld
virtual bool tearDownWorld()
Definition common.h:132
GlobalPrintingFixture::setUp
virtual bool setUp()
Definition common.h:137
GlobalPrintingFixture::~GlobalPrintingFixture
~GlobalPrintingFixture()
Definition common.h:97
GlobalPrintingFixture::_redirect
bool _redirect
Definition common.h:93
GlobalPrintingFixture::_ofs
std::ofstream _ofs
Definition common.h:92
GlobalPrintingFixture::setUpWorld
virtual bool setUpWorld()
Definition common.h:116
coeffs.h
Coefficient rings, fields and other domains suitable for Singular polynomials.
n_Test
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r).
Definition coeffs.h:715
n_coeffType
n_coeffType
Definition coeffs.h:27
n_R
@ n_R
single prescision (6,6) real numbers
Definition coeffs.h:31
n_GF
@ n_GF
\GF{p^n < 2^16}
Definition coeffs.h:32
n_Q
@ n_Q
rational (GMP) numbers
Definition coeffs.h:30
n_Znm
@ n_Znm
only used if HAVE_RINGS is defined
Definition coeffs.h:45
n_algExt
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition coeffs.h:35
n_Zn
@ n_Zn
only used if HAVE_RINGS is defined
Definition coeffs.h:44
n_long_R
@ n_long_R
real floating point (GMP) numbers
Definition coeffs.h:33
n_Z2m
@ n_Z2m
only used if HAVE_RINGS is defined
Definition coeffs.h:46
n_Zp
@ n_Zp
\F{p < 2^31}
Definition coeffs.h:29
n_CF
@ n_CF
?
Definition coeffs.h:48
n_transExt
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition coeffs.h:38
n_unknown
@ n_unknown
Definition coeffs.h:28
n_Z
@ n_Z
only used if HAVE_RINGS is defined
Definition coeffs.h:43
n_long_C
@ n_long_C
complex floating point (GMP) numbers
Definition coeffs.h:41
n_Size
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition coeffs.h:573
n_Write
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition coeffs.h:594
n_Procs_s
Definition coeffs.h:130
argv0
char * argv0
Definition coeffs_test_runner.cpp:14
CASE
#define CASE(A)
s
const CanonicalForm int s
Definition facAbsFact.cc:51
feInitResources
void feInitResources(const char *argv0)
Definition feResource.cc:160
feResource.h
gb_hack.h
T
STATIC_VAR jList * T
Definition janet.cc:30
snumber
'SR_INT' is the type of those integers small enough to fit into 29 bits.
Definition longrat.h:49
CxxTest::doAssertDiffers
void doAssertDiffers(const char *file, unsigned line, const char *xExpr, X x, const char *yExpr, Y y, const char *message)
Definition TestSuite.h:77
CxxTest::doAssertEquals
void doAssertEquals(const char *file, unsigned line, const char *xExpr, X x, const char *yExpr, Y y, const char *message)
Definition TestSuite.h:51
CxxTest::equals
bool equals(X x, Y y)
Definition TestSuite.h:45
CxxTest::differs
bool differs(X x, Y y)
Definition TestSuite.h:71
coeffs
The main handler for Singular numbers which are suitable for Singular polynomials.
numbers.h
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
StringSetS
void StringSetS(const char *st)
Definition reporter.cc:128
PrintS
void PrintS(const char *s)
Definition reporter.cc:288
feStringAppendResources
void feStringAppendResources(int warn)
Definition reporter.cc:402
StringEndS
char * StringEndS()
Definition reporter.cc:151
reporter.h
operator<<
ostream & operator<<(ostream &s, const spectrum &spec)
Definition semic.cc:249
ip_sring
Definition ring.h:254