1 | #include "config.h" |
---|
2 | |
---|
3 | #include <auxiliary.h> |
---|
4 | #include <coeffs.h> |
---|
5 | #include <numbers.h> |
---|
6 | #include <reporter.h> |
---|
7 | #include <omalloc.h> |
---|
8 | |
---|
9 | #include <longrat.h> |
---|
10 | #include <gnumpc.h> |
---|
11 | #include <shortfl.h> |
---|
12 | #include <rmodulon.h> |
---|
13 | #include <rmodulo2m.h> |
---|
14 | |
---|
15 | #include <iostream> |
---|
16 | using namespace std; |
---|
17 | |
---|
18 | |
---|
19 | bool Test(const coeffs r) |
---|
20 | { |
---|
21 | number a = n_Init(666, r); |
---|
22 | n_Test(a,r); |
---|
23 | |
---|
24 | number b = n_Add(a, a, r); |
---|
25 | n_Test(b,r); |
---|
26 | |
---|
27 | StringSetS("a: "); n_Write(a, r);PrintS(StringAppend("\n")); |
---|
28 | StringSetS("b: "); n_Write(b, r);PrintS(StringAppend("\n")); |
---|
29 | |
---|
30 | n_Delete(&a, r); |
---|
31 | n_Delete(&b, r); |
---|
32 | |
---|
33 | return false; |
---|
34 | } |
---|
35 | |
---|
36 | |
---|
37 | |
---|
38 | bool Test(const n_coeffType type) |
---|
39 | { |
---|
40 | |
---|
41 | cout << "Testing coeffs: [" << type << "]: " << endl; |
---|
42 | |
---|
43 | const coeffs r = nInitChar( type, NULL ); |
---|
44 | |
---|
45 | assume( r != NULL ); |
---|
46 | |
---|
47 | nSetChar( r ); |
---|
48 | |
---|
49 | assume( getCoeffType(r) == type ); |
---|
50 | |
---|
51 | assume( r->cfInit != NULL ); |
---|
52 | assume( r->cfWrite != NULL ); |
---|
53 | assume( r->cfAdd != NULL ); |
---|
54 | assume( r->cfDelete != NULL ); |
---|
55 | |
---|
56 | |
---|
57 | if( type == n_Q ) |
---|
58 | { |
---|
59 | assume( r->cfInit == nlInit ); |
---|
60 | assume( r->cfWrite == nlWrite ); |
---|
61 | assume( r->cfAdd == nlAdd ); |
---|
62 | assume( r->cfDelete == nlDelete ); |
---|
63 | } |
---|
64 | else if( type == n_long_C ) |
---|
65 | { |
---|
66 | assume( r->cfInit == ngcInit ); |
---|
67 | assume( r->cfWrite == ngcWrite ); |
---|
68 | assume( r->cfAdd == ngcAdd ); |
---|
69 | assume( r->cfDelete == ngcDelete ); |
---|
70 | } |
---|
71 | else if( type == n_R ) |
---|
72 | { |
---|
73 | assume( r->cfInit == nrInit ); |
---|
74 | assume( r->cfWrite == nrWrite ); |
---|
75 | assume( r->cfAdd == nrAdd ); |
---|
76 | // assume( r->cfDelete == nrDelete ); // No? |
---|
77 | } |
---|
78 | else if( type == n_Z2m ) |
---|
79 | { |
---|
80 | assume( r->cfInit == nr2mInit ); |
---|
81 | assume( r->cfWrite == nr2mWrite ); |
---|
82 | assume( r->cfAdd == nr2mAdd ); |
---|
83 | assume( r->cfDelete == ndDelete ); |
---|
84 | } |
---|
85 | else if( type == n_Zn ) |
---|
86 | { |
---|
87 | assume( r->cfInit == nrnInit ); |
---|
88 | assume( r->cfWrite == nrnWrite ); |
---|
89 | assume( r->cfAdd == nrnAdd ); |
---|
90 | assume( r->cfDelete == nrnDelete ); |
---|
91 | } |
---|
92 | else |
---|
93 | { |
---|
94 | // ... |
---|
95 | } |
---|
96 | |
---|
97 | bool ret = Test( r ); |
---|
98 | |
---|
99 | nKillChar( r ); |
---|
100 | |
---|
101 | return ret; |
---|
102 | } |
---|
103 | |
---|
104 | |
---|
105 | |
---|
106 | |
---|
107 | int main() |
---|
108 | { |
---|
109 | int c = 0; |
---|
110 | |
---|
111 | n_coeffType type; |
---|
112 | |
---|
113 | type = nRegister( n_Q, nlInitChar); assume( type == n_Q ); |
---|
114 | |
---|
115 | if( Test(type) ) |
---|
116 | c ++; |
---|
117 | |
---|
118 | type = nRegister( n_long_C, ngcInitChar); assume( type == n_long_C ); |
---|
119 | if( Test(type) ) |
---|
120 | c ++; |
---|
121 | |
---|
122 | type = nRegister( n_R, nrInitChar); assume( type == n_R ); |
---|
123 | if( Test(type) ) |
---|
124 | c ++; |
---|
125 | |
---|
126 | type = nRegister( n_Zn, nrnInitChar); assume( type == n_Zn ); |
---|
127 | if( Test(type) ) |
---|
128 | c ++; |
---|
129 | |
---|
130 | type = nRegister( n_Z2m, nr2mInitChar); assume( type == n_Z2m ); |
---|
131 | if( Test(type) ) |
---|
132 | c ++; |
---|
133 | |
---|
134 | return c; |
---|
135 | |
---|
136 | } |
---|