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