1 | /* |
2 | Name: imdrover.h |
3 | Purpose: Keeper of the hordes of testing code. |
4 | Author: M. J. Fromberger |
5 | |
6 | Copyright (C) 2002-2007 Michael J. Fromberger, All Rights Reserved. |
7 | |
8 | Permission is hereby granted, free of charge, to any person obtaining a copy |
9 | of this software and associated documentation files (the "Software"), to deal |
10 | in the Software without restriction, including without limitation the rights |
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
12 | copies of the Software, and to permit persons to whom the Software is |
13 | furnished to do so, subject to the following conditions: |
14 | |
15 | The above copyright notice and this permission notice shall be included in |
16 | all copies or substantial portions of the Software. |
17 | |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
24 | SOFTWARE. |
25 | */ |
26 | |
27 | #ifndef IMDROVER_H_ |
28 | #define IMDROVER_H_ |
29 | |
30 | #include <stdbool.h> |
31 | #include <stdio.h> |
32 | |
33 | typedef struct { |
34 | int line; |
35 | char *file; |
36 | char *code; |
37 | int num_inputs; |
38 | char **input; |
39 | int num_outputs; |
40 | char **output; |
41 | } testspec_t; |
42 | |
43 | typedef bool (*test_f)(testspec_t *, FILE *); |
44 | |
45 | /* Call this once at the outset to set up test registers */ |
46 | void init_testing(void); |
47 | void reset_registers(void); |
48 | |
49 | /* Integer tests, and general */ |
50 | bool test_init(testspec_t* t, FILE* ofp); |
51 | bool test_set(testspec_t* t, FILE* ofp); |
52 | bool test_neg(testspec_t* t, FILE* ofp); |
53 | bool test_abs(testspec_t* t, FILE* ofp); |
54 | bool test_add(testspec_t* t, FILE* ofp); |
55 | bool test_sub(testspec_t* t, FILE* ofp); |
56 | bool test_mul(testspec_t* t, FILE* ofp); |
57 | bool test_mulp2(testspec_t* t, FILE* ofp); |
58 | bool test_mulv(testspec_t* t, FILE* ofp); |
59 | bool test_sqr(testspec_t* t, FILE* ofp); |
60 | bool test_div(testspec_t* t, FILE* ofp); |
61 | bool test_divp2(testspec_t* t, FILE* ofp); |
62 | bool test_divv(testspec_t* t, FILE* ofp); |
63 | bool test_expt(testspec_t* t, FILE* ofp); |
64 | bool test_exptv(testspec_t* t, FILE* ofp); |
65 | bool test_exptf(testspec_t* t, FILE* ofp); |
66 | bool test_mod(testspec_t* t, FILE* ofp); |
67 | bool test_gcd(testspec_t* t, FILE* ofp); |
68 | bool test_egcd(testspec_t* t, FILE* ofp); |
69 | bool test_lcm(testspec_t* t, FILE* ofp); |
70 | bool test_sqrt(testspec_t* t, FILE* ofp); |
71 | bool test_root(testspec_t* t, FILE* ofp); |
72 | bool test_invmod(testspec_t* t, FILE* ofp); |
73 | bool test_exptmod(testspec_t* t, FILE* ofp); |
74 | bool test_exptmod_ev(testspec_t* t, FILE* ofp); |
75 | bool test_exptmod_bv(testspec_t* t, FILE* ofp); |
76 | bool test_comp(testspec_t* t, FILE* ofp); |
77 | bool test_ucomp(testspec_t* t, FILE* ofp); |
78 | bool test_zcomp(testspec_t* t, FILE* ofp); |
79 | bool test_vcomp(testspec_t* t, FILE* ofp); |
80 | bool test_uvcomp(testspec_t* t, FILE* ofp); |
81 | bool test_tostr(testspec_t* t, FILE* ofp); |
82 | bool test_tobin(testspec_t* t, FILE* ofp); |
83 | bool test_to_int(testspec_t* t, FILE* ofp); |
84 | bool test_to_uint(testspec_t* t, FILE* ofp); |
85 | bool test_read_binary(testspec_t* t, FILE* ofp); |
86 | bool test_to_uns(testspec_t* t, FILE* ofp); |
87 | bool test_read_uns(testspec_t* t, FILE* ofp); |
88 | bool test_meta(testspec_t* t, FILE* ofp); |
89 | |
90 | /* Rational tests */ |
91 | bool test_qneg(testspec_t* t, FILE* ofp); |
92 | bool test_qrecip(testspec_t* t, FILE* ofp); |
93 | bool test_qabs(testspec_t* t, FILE* ofp); |
94 | bool test_qadd(testspec_t* t, FILE* ofp); |
95 | bool test_qsub(testspec_t* t, FILE* ofp); |
96 | bool test_qmul(testspec_t* t, FILE* ofp); |
97 | bool test_qdiv(testspec_t* t, FILE* ofp); |
98 | bool test_qdiv(testspec_t* t, FILE* ofp); |
99 | bool test_qaddz(testspec_t* t, FILE* ofp); |
100 | bool test_qsubz(testspec_t* t, FILE* ofp); |
101 | bool test_qmulz(testspec_t* t, FILE* ofp); |
102 | bool test_qdivz(testspec_t* t, FILE* ofp); |
103 | bool test_qexpt(testspec_t* t, FILE* ofp); |
104 | bool test_qtostr(testspec_t* t, FILE* ofp); |
105 | bool test_qtodec(testspec_t* t, FILE* ofp); |
106 | bool test_qrdec(testspec_t* t, FILE* ofp); |
107 | |
108 | /* Primality testing tests */ |
109 | bool test_is_prime(testspec_t* t, FILE *ofp); |
110 | |
111 | #endif /* IMDROVER_H_ */ |
112 | |