18 #include "../include/Polynomial.hpp"
19 #include "../include/gmpsupport.hpp"
20 #include "gtest/gtest.h"
49 mpz_class c0=1,c1=2,c2=3;
57 mpz_class c0=1,c1=2,c2=3;
68 mpz_class c0=1,c1=2,c2=3;
77 mpz_class c0=1,c1=2,c2=3;
84 ASSERT_EQ(p.size(),0);
87 mpz_class c0=1,c1=2,c2=3;
95 ASSERT_EQ(p.size(),0);
98 mpz_class c0=1,c1=2,c2=3;
100 ASSERT_THROW(f[3],std::out_of_range);
104 mpz_class c0=1,c1=2,c2=3;
105 mpz_class a0=4,a1=5,a2=6;
119 mpz_class c0=1,c1=2,c2=3,c3=0;
120 mpz_class a0=4,a1=0,a2=6,a3=0;
123 ASSERT_EQ(fc.size(),3);
124 ASSERT_EQ(fa.size(),3);
135 mpz_class c0=1,c1=2,c2=3,c3=0;
136 mpz_class a0=4,a1=0,a2=6,a3=10;
141 ASSERT_EQ(fc.size(),4);
142 ASSERT_EQ(fa.size(),4);
144 ASSERT_EQ(fc[0],c0+a0);
145 ASSERT_EQ(fc[1],c1+a1);
146 ASSERT_EQ(fc[2],c2+a2);
147 ASSERT_EQ(fc[3],c3+a3);
156 mpz_class c0=1,c1=2,c2=3,c3=0;
157 mpz_class a0=4,a1=0,a2=6,a3=10;
161 ASSERT_EQ(fc.size(),4);
163 ASSERT_EQ(fc[0],c0+a0);
164 ASSERT_EQ(fc[1],c1+a1);
165 ASSERT_EQ(fc[2],c2+a2);
166 ASSERT_EQ(fc[3],c3+a3);
170 mpz_class c0=1,c1=2,c2=3,c3=0;
171 mpz_class a0=4,a1=0,a2=6,a3=10;
176 ASSERT_EQ(fc.size(),4);
177 ASSERT_EQ(fa.size(),4);
179 ASSERT_EQ(fc[0],c0-a0);
180 ASSERT_EQ(fc[1],c1-a1);
181 ASSERT_EQ(fc[2],c2-a2);
182 ASSERT_EQ(fc[3],c3-a3);
191 mpz_class c0=1,c1=2,c2=3,c3=0;
192 mpz_class a0=4,a1=0,a2=6,a3=10;
196 ASSERT_EQ(fc.size(),4);
198 ASSERT_EQ(fc[0],c0-a0);
199 ASSERT_EQ(fc[1],c1-a1);
200 ASSERT_EQ(fc[2],c2-a2);
201 ASSERT_EQ(fc[3],c3-a3);
205 mpz_class a0=4,a1=0,a2=6,a3=10;
208 ASSERT_EQ(fa[0],-a0);
209 ASSERT_EQ(fa[1],-a1);
210 ASSERT_EQ(fa[2],-a2);
211 ASSERT_EQ(fa[3],-a3);
214 mpz_class a0=4,a1=0,a2=6,a3=10;
224 mpz_class a0=4,a1=0,a2=6,a3=10;
227 ASSERT_EQ(fa.size(),4);
229 ASSERT_EQ(fa[0],-a0);
230 ASSERT_EQ(fa[1],-a1);
231 ASSERT_EQ(fa[2],-a2);
232 ASSERT_EQ(fa[3],-a3);
237 mpz_class c0=1,c1=2,c2=3,c3=0;
238 mpz_class a0=4,a1=0,a2=6,a3=10;
243 ASSERT_EQ(fc.size(),3);
244 ASSERT_EQ(fa.size(),4);
245 ASSERT_EQ(f.
size(),4);
248 ASSERT_EQ(f[0],c0+a0);
249 ASSERT_EQ(f[1],c1+a1);
250 ASSERT_EQ(f[2],c2+a2);
251 ASSERT_EQ(f[3],c3+a3);
262 mpz_class c0=1,c1=2,c2=3,c3=0;
263 mpz_class a0=4,a1=0,a2=6,a3=10;
268 ASSERT_EQ(fa.size(),4);
269 ASSERT_EQ(f.
size(),4);
272 ASSERT_EQ(f[0],c0+a0);
273 ASSERT_EQ(f[1],c1+a1);
274 ASSERT_EQ(f[2],c2+a2);
275 ASSERT_EQ(f[3],c3+a3);
283 mpz_class c0=1,c1=2,c2=3,c3=10;
284 mpz_class a0=4,a1=0,a2=6,a3=10;
289 ASSERT_EQ(fc.size(),4);
290 ASSERT_EQ(fa.size(),4);
291 ASSERT_EQ(f.
size(),3);
294 ASSERT_EQ(f[0],a0-c0);
295 ASSERT_EQ(f[1],a1-c1);
296 ASSERT_EQ(f[2],a2-c2);
309 mpz_class c0=1,c1=2,c2=3,c3=4;
310 mpz_class a0=4,a1=0,a2=6;
315 ASSERT_EQ(f.
size(),6);
318 ASSERT_EQ(f[0],c0*a0);
319 ASSERT_EQ(f[1],a0*c1+a1*c0);
320 ASSERT_EQ(f[2],a0*c2+a1*c1+a2*c0);
321 ASSERT_EQ(f[3],a0*c3+a1*c2+a2*c1);
322 ASSERT_EQ(f[4],a1*c3+a2*c2);
323 ASSERT_EQ(f[5],a2*c3);
326 ASSERT_EQ(g.
size(),6);
329 ASSERT_EQ(g[0],c0*a0);
330 ASSERT_EQ(g[1],a0*c1+a1*c0);
331 ASSERT_EQ(g[2],a0*c2+a1*c1+a2*c0);
332 ASSERT_EQ(g[3],a0*c3+a1*c2+a2*c1);
333 ASSERT_EQ(g[4],a1*c3+a2*c2);
334 ASSERT_EQ(g[5],a2*c3);
338 int main(
int argc,
char **argv){
339 ::testing::InitGoogleTest(&argc,argv);
340 return RUN_ALL_TESTS();
void appendTerm(FieldT coeff)
Append new terms by pushing back coefficients.
TEST_F(PolynomialMPZTest, constructor_init_list)
int main(int argc, char **argv)
virtual ~PolynomialMPZTest()
Polynomial & minus()
Flip the sign of all coefs.
Contains the definition for the abstract base class which will be used by different multiplication al...