My Project
Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1#ifndef TESTS_COMMON_H
2#define TESTS_COMMON_H
3
4#include <iostream>
5#include <fstream>
6#include <string.h>
7
8#include "cxxtest/TestSuite.h"
10
11#include "misc/auxiliary.h"
12
13#include "coeffs/coeffs.h"
14#include "coeffs/numbers.h"
15
16#include "reporter/reporter.h"
18
19#ifndef PLURAL_INTERNAL_DECLARATIONS
20#define PLURAL_INTERNAL_DECLARATIONS
21#endif
22
23#include "polys/nc/gb_hack.h"
24
25// #pragma GCC diagnostic ignored "-Wwrite-strings"
26namespace
27{
28 static inline std::ostream& operator<< (std::ostream& o, const n_coeffType& type)
29 {
30#define CASE(A) case A: return o << (" " # A) << " ";
31 switch( type )
32 {
34 CASE(n_Zp);
35 CASE(n_Q);
36 CASE(n_R);
37 CASE(n_GF);
42 CASE(n_Z);
43 CASE(n_Zn);
44 CASE(n_Znm);
45 CASE(n_Z2m);
46 CASE(n_CF);
47 default: return o << "Unknown type: [" << (unsigned long) type << "]";
48 }
49#undef CASE
50 return o;
51 }
52
53 template<typename T>
54 static inline std::string _2S(T i)
55 {
56 std::stringstream ss;
57 ss << i;
58// std::string s = ss.str();
59 return ss.str();
60 }
61
62
63 static inline std::string _2S(number a, const coeffs r)
64 {
65 n_Test(a,r);
66 StringSetS("");
67 n_Write(a, r);
68
69 std::stringstream ss;
70 {
71 char* s = StringEndS(); ss << s; omFree(s);
72 }
73
74 return ss.str();
75
76 }
77
78 static inline void PrintSized(/*const*/ number a, const coeffs r, BOOLEAN eoln = TRUE)
79 {
80 std::clog << _2S(a, r) << ", of size: " << n_Size(a, r);
81
82 if( eoln )
83 std::clog << std::endl;
84 }
85
86
87
88}
89
91{
92 std::ofstream _ofs;
94 public:
95 GlobalPrintingFixture(bool redirect = false): _redirect(redirect){}
96
98 {
99 if( _ofs)
100 _ofs.close();
101 }
102
103 void Redirect()
104 {
105 const int ll = strlen(argv0);
106 const int l = 5 + ll;
107 char* s = (char *)omAlloc0(l);
108 s = strncpy(s, argv0, ll);
109 strncpy(s + ll, ".log", 5);
110 _ofs.open(s); // , ios_base::out)
112
113 std::clog.rdbuf(_ofs.rdbuf());
114 }
115
116 virtual bool setUpWorld()
117 {
118 if( _redirect )
119 Redirect();
120
121 std::clog << std::endl << ( "<world>" ) << std::endl << std::endl;
122 feInitResources(argv0);
123
124 StringSetS("ressources in use (as reported by feStringAppendResources(0):\n");
126
127 { char* s = StringEndS(); PrintS(s); omFree(s); }
128
129 return true;
130 }
131
132 virtual bool tearDownWorld()
133 {
134 std::clog << std::endl << std::endl <<( "</world>" ) << std::endl << std::endl ;
135 return true;
136 }
137 virtual bool setUp() { std::clog << std::endl << std::endl <<( "<test>" ) << std::endl << std::endl; return true; }
138 virtual bool tearDown() { std::clog << std::endl << std::endl <<( "</test>" ) << std::endl << std::endl; return true; }
139};
140
141
142template void CxxTest::doAssertDiffers<n_Procs_s*, void*>(char const*, unsigned int, char const*, n_Procs_s*, char const*, void*, char const*);
143template 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*);
144template 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*);
145template 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*);
146template 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*);
147template 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*);
148template void CxxTest::doAssertEquals<int, int>(char const*, unsigned int, char const*, int, char const*, int, char const*);
149template void CxxTest::doAssertEquals<n_coeffType, n_coeffType>(char const*, unsigned int, char const*, n_coeffType, char const*, n_coeffType, char const*);
150template 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*);
151template 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*);
152template 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*);
153
154template bool CxxTest::differs<n_Procs_s*, void*>(n_Procs_s*, void*);
155template bool CxxTest::differs<snumber* (*)(long, n_Procs_s*), void*>(snumber* (*)(long, n_Procs_s*), void*);
156template bool CxxTest::differs<snumber* (*)(snumber*, snumber*, n_Procs_s*), void*>(snumber* (*)(snumber*, snumber*, n_Procs_s*), void*);
157template bool CxxTest::differs<void (*)(n_Procs_s*, int), void*>(void (*)(n_Procs_s*, int), void*);
158template bool CxxTest::differs<void (*)(snumber**, n_Procs_s*), void*>(void (*)(snumber**, n_Procs_s*), void*);
159template bool CxxTest::differs<void (*)(snumber*&, n_Procs_s*), void*>(void (*)(snumber*&, n_Procs_s*), void*);
160template bool CxxTest::equals<int, int>(int, int);
161template bool CxxTest::equals<n_coeffType, n_coeffType>(n_coeffType, n_coeffType);
162template bool CxxTest::equals<snumber* (*)(long, n_Procs_s*), snumber* (*)(long, n_Procs_s*)>(snumber* (*)(long, n_Procs_s*), snumber* (*)(long, n_Procs_s*));
163template 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*));
164template bool CxxTest::equals<void (*)(snumber**, n_Procs_s*), void (*)(snumber**, n_Procs_s*)>(void (*)(snumber**, n_Procs_s*), void (*)(snumber**, n_Procs_s*));
165template char* CxxTest::numberToString<long>(long, char*, long, unsigned int, unsigned int);
166
167template void CxxTest::doAssertDiffers<ip_sring*, void*>(char const*, unsigned int, char const*, ip_sring*, char const*, void*, char const*);
168template void CxxTest::doAssertEquals<short, int>(char const*, unsigned int, char const*, short, char const*, int, char const*);
169
170template bool CxxTest::differs<ip_sring*, void*>(ip_sring*, void*);
171template bool CxxTest::equals<short, int>(short, int);
172
173#endif /* TESTS_COMMON_H */
All the auxiliary stuff.
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
void * ADDRESS
Definition: auxiliary.h:119
int l
Definition: cfEzgcd.cc:100
int i
Definition: cfEzgcd.cc:132
GlobalPrintingFixture(bool redirect=false)
Definition: common.h:95
virtual bool tearDown()
Definition: common.h:138
virtual bool tearDownWorld()
Definition: common.h:132
virtual bool setUp()
Definition: common.h:137
std::ofstream _ofs
Definition: common.h:92
virtual bool setUpWorld()
Definition: common.h:116
Coefficient rings, fields and other domains suitable for Singular polynomials.
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition: coeffs.h:709
n_coeffType
Definition: coeffs.h:27
@ n_R
single prescision (6,6) real numbers
Definition: coeffs.h:31
@ n_GF
\GF{p^n < 2^16}
Definition: coeffs.h:32
@ n_Q
rational (GMP) numbers
Definition: coeffs.h:30
@ n_Znm
only used if HAVE_RINGS is defined
Definition: coeffs.h:45
@ 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
only used if HAVE_RINGS is defined
Definition: coeffs.h:44
@ n_long_R
real floating point (GMP) numbers
Definition: coeffs.h:33
@ n_Z2m
only used if HAVE_RINGS is defined
Definition: coeffs.h:46
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:29
@ n_CF
?
Definition: coeffs.h:48
@ 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
Definition: coeffs.h:28
@ n_Z
only used if HAVE_RINGS is defined
Definition: coeffs.h:43
@ n_long_C
complex floating point (GMP) numbers
Definition: coeffs.h:41
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:567
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:588
#define CASE(A)
const CanonicalForm int s
Definition: facAbsFact.cc:51
void feInitResources(const char *argv0)
Definition: feResource.cc:163
STATIC_VAR jList * T
Definition: janet.cc:30
'SR_INT' is the type of those integers small enough to fit into 29 bits.
Definition: longrat.h:49
The main handler for Singular numbers which are suitable for Singular polynomials.
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omFree(addr)
Definition: omAllocDecl.h:261
#define omAlloc0(size)
Definition: omAllocDecl.h:211
void StringSetS(const char *st)
Definition: reporter.cc:128
void PrintS(const char *s)
Definition: reporter.cc:284
void feStringAppendResources(int warn)
Definition: reporter.cc:398
char * StringEndS()
Definition: reporter.cc:151
ostream & operator<<(ostream &s, const spectrum &spec)
Definition: semic.cc:249
Definition: ring.h:248