My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
libpolys
tests
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
"
9
#include "
cxxtest/GlobalFixture.h
"
10
11
#include "
misc/auxiliary.h
"
12
13
#include "
coeffs/coeffs.h
"
14
#include "
coeffs/numbers.h
"
15
16
#include "
reporter/reporter.h
"
17
#include "
resources/feResource.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"
26
namespace
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
{
33
CASE
(
n_unknown
);
34
CASE
(
n_Zp
);
35
CASE
(
n_Q
);
36
CASE
(
n_R
);
37
CASE
(
n_GF
);
38
CASE
(
n_long_R
);
39
CASE
(
n_algExt
);
40
CASE
(
n_transExt
);
41
CASE
(
n_long_C
);
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
90
class
GlobalPrintingFixture
:
public
CxxTest::GlobalFixture
91
{
92
std::ofstream
_ofs
;
93
bool
_redirect
;
94
public
:
95
GlobalPrintingFixture
(
bool
redirect =
false
):
_redirect
(redirect){}
96
97
~GlobalPrintingFixture
()
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)
111
omFreeSize
((
ADDRESS
)
s
,
l
);
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
(
"resources in use (as reported by feStringAppendResources(0):\n"
);
125
feStringAppendResources
(0);
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
142
template
void
CxxTest::doAssertDiffers<n_Procs_s*, void*>
(
char
const
*,
unsigned
int
,
char
const
*,
n_Procs_s
*,
char
const
*,
void
*,
char
const
*);
143
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
*);
144
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
*);
145
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
*);
146
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
*);
147
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
*);
148
template
void
CxxTest::doAssertEquals<int, int>
(
char
const
*,
unsigned
int
,
char
const
*,
int
,
char
const
*,
int
,
char
const
*);
149
template
void
CxxTest::doAssertEquals<n_coeffType, n_coeffType>
(
char
const
*,
unsigned
int
,
char
const
*,
n_coeffType
,
char
const
*,
n_coeffType
,
char
const
*);
150
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
*);
151
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
*);
152
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
*);
153
154
template
bool
CxxTest::differs<n_Procs_s*, void*>
(
n_Procs_s
*,
void
*);
155
template
bool
CxxTest::differs<snumber* (*)(long, n_Procs_s*), void*>
(
snumber
* (*)(
long
,
n_Procs_s
*),
void
*);
156
template
bool
CxxTest::differs<snumber* (*)(snumber*, snumber*, n_Procs_s*), void*>
(
snumber
* (*)(
snumber
*,
snumber
*,
n_Procs_s
*),
void
*);
157
template
bool
CxxTest::differs<void (*)(n_Procs_s*, int), void*>
(
void
(*)(
n_Procs_s
*,
int
),
void
*);
158
template
bool
CxxTest::differs<void (*)(snumber**, n_Procs_s*), void*>
(
void
(*)(
snumber
**,
n_Procs_s
*),
void
*);
159
template
bool
CxxTest::differs<void (*)(snumber*&, n_Procs_s*), void*>
(
void
(*)(
snumber
*&,
n_Procs_s
*),
void
*);
160
template
bool
CxxTest::equals<int, int>
(
int
,
int
);
161
template
bool
CxxTest::equals<n_coeffType, n_coeffType>
(
n_coeffType
,
n_coeffType
);
162
template
bool
CxxTest::equals<snumber* (*)(long, n_Procs_s*), snumber* (*)(long, n_Procs_s*)>
(
snumber
* (*)(
long
,
n_Procs_s
*),
snumber
* (*)(
long
,
n_Procs_s
*));
163
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
*));
164
template
bool
CxxTest::equals<void (*)(snumber**, n_Procs_s*), void (*)(snumber**, n_Procs_s*)>
(
void
(*)(
snumber
**,
n_Procs_s
*),
void
(*)(
snumber
**,
n_Procs_s
*));
165
template
char
* CxxTest::numberToString<long>(
long
,
char
*,
long
,
unsigned
int
,
unsigned
int
);
166
167
template
void
CxxTest::doAssertDiffers<ip_sring*, void*>
(
char
const
*,
unsigned
int
,
char
const
*,
ip_sring
*,
char
const
*,
void
*,
char
const
*);
168
template
void
CxxTest::doAssertEquals<short, int>
(
char
const
*,
unsigned
int
,
char
const
*,
short
,
char
const
*,
int
,
char
const
*);
169
170
template
bool
CxxTest::differs<ip_sring*, void*>
(
ip_sring
*,
void
*);
171
template
bool
CxxTest::equals<short, int>
(
short
,
int
);
172
173
#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
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
n_Procs_s
Definition
coeffs.h:130
Generated on
for My Project by
doxygen 1.18.0
for
Singular