Deleted Added
full compact
legacy_test.c (189092) legacy_test.c (269534)
1/*-
2 * Copyright (c) 2006, Simon L. Nielsen <simon@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2006, Simon L. Nielsen <simon@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/tools/regression/lib/libmp/test-libmp.c 189092 2009-02-26 21:43:15Z ed $");
28__FBSDID("$FreeBSD: head/lib/libmp/tests/legacy_test.c 269534 2014-08-04 22:10:07Z ngie $");
29
30#include <mp.h>
31#include <stdio.h>
32#include <string.h>
33#include <sysexits.h>
34
35MINT *c0, *c1, *c2, *c3, *c5, *c6, *c8, *c10, *c14, *c15, *c25, \
36 *c42,*c43, *c44, *c45, *t0, *t1;

--- 4 unchanged lines hidden (view full) ---

41{
42
43 if (mp_mcmp(mp1, mp2) == 0)
44 printf("ok %d - %s\n", ++tnr, tname);
45 else
46 printf("not ok - %d %s\n", ++tnr, tname);
47}
48
29
30#include <mp.h>
31#include <stdio.h>
32#include <string.h>
33#include <sysexits.h>
34
35MINT *c0, *c1, *c2, *c3, *c5, *c6, *c8, *c10, *c14, *c15, *c25, \
36 *c42,*c43, *c44, *c45, *t0, *t1;

--- 4 unchanged lines hidden (view full) ---

41{
42
43 if (mp_mcmp(mp1, mp2) == 0)
44 printf("ok %d - %s\n", ++tnr, tname);
45 else
46 printf("not ok - %d %s\n", ++tnr, tname);
47}
48
49static int
49static void
50testsimpel(void)
51{
52 const char str42[] = "2a";
53 MINT *t2;
54 char *s;
55
56 mp_madd(c42, c1, t0);
57 testmcmp(c43, t0, "madd0");

--- 11 unchanged lines hidden (view full) ---

69 s = mp_mtox(t2);
70 if (strcmp(str42, s) == 0)
71 printf("ok %d - %s\n", ++tnr, "mtox0");
72 else
73 printf("not ok %d - %s\n", ++tnr, "mtox0");
74 mp_mfree(t2);
75}
76
50testsimpel(void)
51{
52 const char str42[] = "2a";
53 MINT *t2;
54 char *s;
55
56 mp_madd(c42, c1, t0);
57 testmcmp(c43, t0, "madd0");

--- 11 unchanged lines hidden (view full) ---

69 s = mp_mtox(t2);
70 if (strcmp(str42, s) == 0)
71 printf("ok %d - %s\n", ++tnr, "mtox0");
72 else
73 printf("not ok %d - %s\n", ++tnr, "mtox0");
74 mp_mfree(t2);
75}
76
77static int
77static void
78testgcd(void)
79{
80
81 mp_gcd(c10, c15, t0);
82 testmcmp(t0, c5, "gcd0");
83}
84
78testgcd(void)
79{
80
81 mp_gcd(c10, c15, t0);
82 testmcmp(t0, c5, "gcd0");
83}
84
85static int
85static void
86testmsqrt(void)
87{
88
89 mp_msqrt(c25, t0, t1);
90 testmcmp(t0, c5, "msqrt0");
91 testmcmp(t1, c0, "msqrt1");
92 mp_msqrt(c42, t0, t1);
93 testmcmp(t0, c6, "msqrt2");
94 testmcmp(t1, c6, "msqrt3");
95}
96
86testmsqrt(void)
87{
88
89 mp_msqrt(c25, t0, t1);
90 testmcmp(t0, c5, "msqrt0");
91 testmcmp(t1, c0, "msqrt1");
92 mp_msqrt(c42, t0, t1);
93 testmcmp(t0, c6, "msqrt2");
94 testmcmp(t1, c6, "msqrt3");
95}
96
97static int
97static void
98testdiv(void)
99{
100 short ro;
101 MINT *t2;
102
103 mp_mdiv(c42, c5, t0, t1);
104 testmcmp(t0, c8, "mdiv0");
105 testmcmp(t1, c2, "mdiv1");

--- 10 unchanged lines hidden (view full) ---

116
117 mp_sdiv(c10, 8, t0, &ro);
118 testmcmp(t0, c1, "sdiv2");
119 t2 = mp_itom(ro); // Simpler to use common testmcmp()
120 testmcmp(t2, c2, "sdiv3");
121 mp_mfree(t2);
122}
123
98testdiv(void)
99{
100 short ro;
101 MINT *t2;
102
103 mp_mdiv(c42, c5, t0, t1);
104 testmcmp(t0, c8, "mdiv0");
105 testmcmp(t1, c2, "mdiv1");

--- 10 unchanged lines hidden (view full) ---

116
117 mp_sdiv(c10, 8, t0, &ro);
118 testmcmp(t0, c1, "sdiv2");
119 t2 = mp_itom(ro); // Simpler to use common testmcmp()
120 testmcmp(t2, c2, "sdiv3");
121 mp_mfree(t2);
122}
123
124static int
124static void
125testmult(void)
126{
127
128 mp_mult(c5, c2, t0);
129 testmcmp(t0, c10, "mmult0");
130 mp_mult(c3, c14, t0);
131 testmcmp(t0, c42, "mmult1");
132}
133
125testmult(void)
126{
127
128 mp_mult(c5, c2, t0);
129 testmcmp(t0, c10, "mmult0");
130 mp_mult(c3, c14, t0);
131 testmcmp(t0, c42, "mmult1");
132}
133
134static int
134static void
135testpow(void)
136{
137
138 mp_pow(c2, c3, c10, t0);
139 testmcmp(t0, c8, "pow0");
140 mp_pow(c2, c3, c3, t0);
141 testmcmp(t0, c2, "pow1");
142 mp_rpow(c2, 3, t0);

--- 69 unchanged lines hidden ---
135testpow(void)
136{
137
138 mp_pow(c2, c3, c10, t0);
139 testmcmp(t0, c8, "pow0");
140 mp_pow(c2, c3, c3, t0);
141 testmcmp(t0, c2, "pow1");
142 mp_rpow(c2, 3, t0);

--- 69 unchanged lines hidden ---