spielwiese
Last change
on this file since 6c084af was
4f684a,
checked in by Oleksandr Motsak <motsak@…>, 13 years ago
|
ADD: unit tests for polys
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | #ifndef TESTS_COMMON_H |
---|
2 | #define TESTS_COMMON_H |
---|
3 | |
---|
4 | #include <misc/auxiliary.h> |
---|
5 | |
---|
6 | #include <coeffs/coeffs.h> |
---|
7 | #include <coeffs/numbers.h> |
---|
8 | |
---|
9 | #include <iostream> |
---|
10 | |
---|
11 | |
---|
12 | // #pragma GCC diagnostic ignored "-Wwrite-strings" |
---|
13 | namespace |
---|
14 | { |
---|
15 | static inline std::ostream& operator<< (std::ostream& o, const n_coeffType& type) |
---|
16 | { |
---|
17 | #define CASE(A) case A: return o << (" " # A) << " "; |
---|
18 | switch( type ) |
---|
19 | { |
---|
20 | CASE(n_unknown); |
---|
21 | CASE(n_Zp); |
---|
22 | CASE(n_Q); |
---|
23 | CASE(n_R); |
---|
24 | CASE(n_GF); |
---|
25 | CASE(n_long_R); |
---|
26 | CASE(n_Zp_a); |
---|
27 | CASE(n_Q_a); |
---|
28 | CASE(n_long_C); |
---|
29 | CASE(n_Z); |
---|
30 | CASE(n_Zn); |
---|
31 | CASE(n_Zpn); |
---|
32 | CASE(n_Z2m); |
---|
33 | CASE(n_CF); |
---|
34 | default: return o << "Unknown type: [" << (const unsigned long) type << "]"; |
---|
35 | } |
---|
36 | #undef CASE |
---|
37 | return o; |
---|
38 | } |
---|
39 | |
---|
40 | template<typename T> |
---|
41 | static inline std::string _2S(T i) |
---|
42 | { |
---|
43 | std::stringstream ss; |
---|
44 | ss << i; |
---|
45 | // std::string s = ss.str(); |
---|
46 | return ss.str(); |
---|
47 | } |
---|
48 | |
---|
49 | |
---|
50 | static inline std::string _2S(number a, const coeffs r) |
---|
51 | { |
---|
52 | n_Test(a,r); |
---|
53 | StringSetS(""); |
---|
54 | n_Write(a, r); |
---|
55 | |
---|
56 | const char* s = StringAppendS(""); |
---|
57 | |
---|
58 | std::stringstream ss; ss << s; |
---|
59 | |
---|
60 | StringSetS(""); |
---|
61 | return ss.str(); |
---|
62 | |
---|
63 | } |
---|
64 | |
---|
65 | static inline void PrintSized(/*const*/ number a, const coeffs r, BOOLEAN eoln = TRUE) |
---|
66 | { |
---|
67 | std::clog << _2S(a, r) << ", of size: " << n_Size(a, r); |
---|
68 | |
---|
69 | if( eoln ) |
---|
70 | std::clog << std::endl; |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | |
---|
75 | } |
---|
76 | |
---|
77 | |
---|
78 | #endif /* TESTS_COMMON_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.