1#![doc(html_root_url = "https://docs.rs/mpir/0.3.1")]
2pub mod prim;
22pub use crate::prim::{*, typ::*, mpz::*, mpf::*, mpq::*, randstate::*};
23pub mod util;
26pub use crate::util::{*};
27
28pub mod minimum;
29
30#[cfg(test)]
31mod tests {
32 use super::*;
33 use super::minimum::{
34 calc_mpz_test,
35 calc_fact_test,
36 calc_fib_test,
37 calc_gcd_test,
38 calc_lcm_test,
39 calc_mod_prime_test,
40 calc_binomial_coefficient_test,
41 calc_mpf_prec64_test, calc_rand_test, calc_fit_test, calc_logical_test,
45 calc_mpq_test,
46 compare_test, significant_digits_test, calc_pi_gauss_legendre_test, calc_pi_euler_test, calc_napier_test, ept_test};
52 use serial_test::serial;
53
54 #[test]
56 fn test_mpz() {
57 let a = &mut mpz_s::new();
58 mpz_init_set_si(a, -123);
59 assert_eq!(format!("{:?}", a),
60 "1, -1 000000000000007b");
61 }
62
63 #[test]
65 #[serial] fn test_mpf() {
67 mpf_set_default_prec(64); let f = &mut mpf_s::new();
69 mpf_init_set_d(f, -0.3);
70 assert_eq!(format!("{:?}", f),
71 "2, -2, 0 0000000000000000 4ccccccccccccc00");
72 }
73
74 #[test]
76 fn test_mpq() {
77 let q = &mut mpq_s::new();
78 mpq_init(q);
79 mpq_set_ui(q, 2, 8);
80 assert_eq!(format!("{:?}", q),
81 "(1, 1 0000000000000002) / (1, 1 0000000000000008)");
82 }
83
84 #[test]
86 fn test_calc_mpz() {
87 assert_eq!(calc_mpz_test(), ());
88 }
89
90 #[test]
92 fn test_calc_fact() {
93 assert_eq!(calc_fact_test(), ());
94 }
95
96 #[test]
98 fn test_calc_fib() {
99 assert_eq!(calc_fib_test(), ());
100 }
101
102 #[test]
104 fn test_calc_gcd() {
105 assert_eq!(calc_gcd_test(), ());
106 }
107
108 #[test]
110 fn test_calc_lcm() {
111 assert_eq!(calc_lcm_test(), ());
112 }
113
114 #[test]
116 fn test_calc_mod_prime() {
117 assert_eq!(calc_mod_prime_test(), ());
118 }
119
120 #[test]
122 fn test_calc_binomial_coefficient() {
123 assert_eq!(calc_binomial_coefficient_test(), ());
124 }
125
126 #[test]
128 #[serial] fn test_calc_mpf_prec64() {
130 assert_eq!(calc_mpf_prec64_test(), ());
131 }
132
133 #[test]
135 #[serial] fn test_calc_rand() {
137 assert_eq!(calc_rand_test(), ());
138 }
139
140 #[test]
142 #[serial] fn test_calc_fit() {
144 assert_eq!(calc_fit_test(), ());
145 }
146
147 #[test]
149 fn test_calc_logical() {
150 assert_eq!(calc_logical_test(), ());
151 }
152
153 #[test]
155 fn test_calc_mpq() {
156 assert_eq!(calc_mpq_test(), ());
157 }
158
159 #[test]
161 #[serial] fn test_compare() {
163 assert_eq!(compare_test(), ());
164 }
165
166 #[test]
168 #[serial] fn test_significant_digits() {
170 assert_eq!(significant_digits_test(), ());
171 }
172
173 #[test]
175 #[serial] fn test_calc_pi_gauss_legendre() {
177 assert_eq!(calc_pi_gauss_legendre_test(), ());
178 }
179
180 #[test]
182 #[serial] fn test_calc_pi_euler() {
184 assert_eq!(calc_pi_euler_test(), ());
185 }
186
187 #[test]
189 #[serial] fn test_calc_napier() {
191 assert_eq!(calc_napier_test(), ());
192 }
193
194 #[test]
196 fn test_ept() {
197 assert_eq!(ept_test(), ());
198 }
199}