18 #include "../include/Polynomial.ipp"
19 #include "gtest/gtest.h"
49 ASSERT_EQ(f.
size(),0);
52 double c0=1,c1=2,c2=3;
54 ASSERT_DOUBLE_EQ(f[0],c0);
55 ASSERT_DOUBLE_EQ(f[1],c1);
56 ASSERT_DOUBLE_EQ(f[2],c2);
60 double c0=1,c1=2,c2=3;
61 std::vector<double> c {c0,c1,c2};
63 ASSERT_DOUBLE_EQ(f[0],c0);
64 ASSERT_DOUBLE_EQ(f[1],c1);
65 ASSERT_DOUBLE_EQ(f[2],c2);
68 double c0=1,c1=2,c2=3;
73 ASSERT_DOUBLE_EQ(f[0],c0);
74 ASSERT_DOUBLE_EQ(f[1],c1);
75 ASSERT_DOUBLE_EQ(f[2],c2);
79 double c0=1,c1=2,c2=3;
82 ASSERT_DOUBLE_EQ(f[0],c0);
83 ASSERT_DOUBLE_EQ(f[1],c1);
84 ASSERT_DOUBLE_EQ(f[2],c2);
88 double c0=1,c1=2,c2=3;
91 ASSERT_DOUBLE_EQ(f[0],c0);
92 ASSERT_DOUBLE_EQ(f[1],c1);
93 ASSERT_DOUBLE_EQ(f[2],c2);
95 ASSERT_EQ(p.size(),0);
98 double c0=1,c1=2,c2=3;
102 ASSERT_DOUBLE_EQ(f[0],c0);
103 ASSERT_DOUBLE_EQ(f[1],c1);
104 ASSERT_DOUBLE_EQ(f[2],c2);
106 ASSERT_EQ(p.size(),0);
109 double c0=1,c1=2,c2=3;
111 ASSERT_THROW(f[3],std::out_of_range);
115 double c0=1,c1=2,c2=3;
116 double a0=4,a1=5,a2=6;
120 ASSERT_DOUBLE_EQ(fc[0],a0);
121 ASSERT_DOUBLE_EQ(fc[1],a1);
122 ASSERT_DOUBLE_EQ(fc[2],a2);
123 ASSERT_DOUBLE_EQ(fa[0],c0);
124 ASSERT_DOUBLE_EQ(fa[1],c1);
125 ASSERT_DOUBLE_EQ(fa[2],c2);
130 double c0=1,c1=2,c2=3,c3=0;
131 double a0=4,a1=0,a2=6,a3=0;
134 ASSERT_EQ(fc.size(),3);
135 ASSERT_EQ(fa.size(),3);
136 ASSERT_DOUBLE_EQ(fc[0],c0);
137 ASSERT_DOUBLE_EQ(fc[1],c1);
138 ASSERT_DOUBLE_EQ(fc[2],c2);
139 ASSERT_DOUBLE_EQ(fa[0],a0);
140 ASSERT_DOUBLE_EQ(fa[1],a1);
141 ASSERT_DOUBLE_EQ(fa[2],a2);
146 double c0=1,c1=2,c2=3,c3=0;
147 double a0=4,a1=0,a2=6,a3=10;
152 ASSERT_EQ(fc.size(),4);
153 ASSERT_EQ(fa.size(),4);
155 ASSERT_DOUBLE_EQ(fc[0],c0+a0);
156 ASSERT_DOUBLE_EQ(fc[1],c1+a1);
157 ASSERT_DOUBLE_EQ(fc[2],c2+a2);
158 ASSERT_DOUBLE_EQ(fc[3],c3+a3);
159 ASSERT_DOUBLE_EQ(fa[0],a0);
160 ASSERT_DOUBLE_EQ(fa[1],a1);
161 ASSERT_DOUBLE_EQ(fa[2],a2);
162 ASSERT_DOUBLE_EQ(fa[3],a3);
167 double c0=1,c1=2,c2=3,c3=0;
168 double a0=4,a1=0,a2=6,a3=10;
172 ASSERT_EQ(fc.size(),4);
174 ASSERT_DOUBLE_EQ(fc[0],c0+a0);
175 ASSERT_DOUBLE_EQ(fc[1],c1+a1);
176 ASSERT_DOUBLE_EQ(fc[2],c2+a2);
177 ASSERT_DOUBLE_EQ(fc[3],c3+a3);
181 double c0=1,c1=2,c2=3,c3=0;
182 double a0=4,a1=0,a2=6,a3=10;
187 ASSERT_EQ(fc.size(),4);
188 ASSERT_EQ(fa.size(),4);
190 ASSERT_DOUBLE_EQ(fc[0],c0-a0);
191 ASSERT_DOUBLE_EQ(fc[1],c1-a1);
192 ASSERT_DOUBLE_EQ(fc[2],c2-a2);
193 ASSERT_DOUBLE_EQ(fc[3],c3-a3);
194 ASSERT_DOUBLE_EQ(fa[0],a0);
195 ASSERT_DOUBLE_EQ(fa[1],a1);
196 ASSERT_DOUBLE_EQ(fa[2],a2);
197 ASSERT_DOUBLE_EQ(fa[3],a3);
202 double c0=1,c1=2,c2=3,c3=0;
203 double a0=4,a1=0,a2=6,a3=10;
207 ASSERT_EQ(fc.size(),4);
209 ASSERT_DOUBLE_EQ(fc[0],c0-a0);
210 ASSERT_DOUBLE_EQ(fc[1],c1-a1);
211 ASSERT_DOUBLE_EQ(fc[2],c2-a2);
212 ASSERT_DOUBLE_EQ(fc[3],c3-a3);
216 double a0=4,a1=0,a2=6,a3=10;
219 ASSERT_DOUBLE_EQ(fa[0],-a0);
220 ASSERT_DOUBLE_EQ(fa[1],-a1);
221 ASSERT_DOUBLE_EQ(fa[2],-a2);
222 ASSERT_DOUBLE_EQ(fa[3],-a3);
225 double a0=4,a1=0,a2=6,a3=10;
229 ASSERT_DOUBLE_EQ(f[0],-a0);
230 ASSERT_DOUBLE_EQ(f[1],-a1);
231 ASSERT_DOUBLE_EQ(f[2],-a2);
232 ASSERT_DOUBLE_EQ(f[3],-a3);
235 double a0=4,a1=0,a2=6,a3=10;
238 ASSERT_EQ(fa.size(),4);
240 ASSERT_DOUBLE_EQ(fa[0],-a0);
241 ASSERT_DOUBLE_EQ(fa[1],-a1);
242 ASSERT_DOUBLE_EQ(fa[2],-a2);
243 ASSERT_DOUBLE_EQ(fa[3],-a3);
248 double c0=1,c1=2,c2=3,c3=0;
249 double a0=4,a1=0,a2=6,a3=10;
254 ASSERT_EQ(fc.size(),3);
255 ASSERT_EQ(fa.size(),4);
256 ASSERT_EQ(f.
size(),4);
259 ASSERT_DOUBLE_EQ(f[0],c0+a0);
260 ASSERT_DOUBLE_EQ(f[1],c1+a1);
261 ASSERT_DOUBLE_EQ(f[2],c2+a2);
262 ASSERT_DOUBLE_EQ(f[3],c3+a3);
263 ASSERT_DOUBLE_EQ(fa[0],a0);
264 ASSERT_DOUBLE_EQ(fa[1],a1);
265 ASSERT_DOUBLE_EQ(fa[2],a2);
266 ASSERT_DOUBLE_EQ(fa[3],a3);
267 ASSERT_DOUBLE_EQ(fc[0],c0);
268 ASSERT_DOUBLE_EQ(fc[1],c1);
269 ASSERT_DOUBLE_EQ(fc[2],c2);
273 double c0=1,c1=2,c2=3,c3=0;
274 double a0=4,a1=0,a2=6,a3=10;
279 ASSERT_EQ(fa.size(),4);
280 ASSERT_EQ(f.
size(),4);
283 ASSERT_DOUBLE_EQ(f[0],c0+a0);
284 ASSERT_DOUBLE_EQ(f[1],c1+a1);
285 ASSERT_DOUBLE_EQ(f[2],c2+a2);
286 ASSERT_DOUBLE_EQ(f[3],c3+a3);
287 ASSERT_DOUBLE_EQ(fa[0],a0);
288 ASSERT_DOUBLE_EQ(fa[1],a1);
289 ASSERT_DOUBLE_EQ(fa[2],a2);
290 ASSERT_DOUBLE_EQ(fa[3],a3);
294 double c0=1,c1=2,c2=3,c3=10;
295 double a0=4,a1=0,a2=6,a3=10;
300 ASSERT_EQ(fc.size(),4);
301 ASSERT_EQ(fa.size(),4);
302 ASSERT_EQ(f.
size(),3);
305 ASSERT_DOUBLE_EQ(f[0],a0-c0);
306 ASSERT_DOUBLE_EQ(f[1],a1-c1);
307 ASSERT_DOUBLE_EQ(f[2],a2-c2);
308 ASSERT_DOUBLE_EQ(fa[0],a0);
309 ASSERT_DOUBLE_EQ(fa[1],a1);
310 ASSERT_DOUBLE_EQ(fa[2],a2);
311 ASSERT_DOUBLE_EQ(fa[3],a3);
312 ASSERT_DOUBLE_EQ(fc[0],c0);
313 ASSERT_DOUBLE_EQ(fc[1],c1);
314 ASSERT_DOUBLE_EQ(fc[2],c2);
320 double c0=1,c1=2,c2=3,c3=4;
321 double a0=4,a1=0,a2=6;
326 ASSERT_EQ(f.
size(),6);
329 ASSERT_DOUBLE_EQ(f[0],c0*a0);
330 ASSERT_DOUBLE_EQ(f[1],a0*c1+a1*c0);
331 ASSERT_DOUBLE_EQ(f[2],a0*c2+a1*c1+a2*c0);
332 ASSERT_DOUBLE_EQ(f[3],a0*c3+a1*c2+a2*c1);
333 ASSERT_DOUBLE_EQ(f[4],a1*c3+a2*c2);
334 ASSERT_DOUBLE_EQ(f[5],a2*c3);
337 ASSERT_EQ(g.
size(),6);
340 ASSERT_DOUBLE_EQ(g[0],c0*a0);
341 ASSERT_DOUBLE_EQ(g[1],a0*c1+a1*c0);
342 ASSERT_DOUBLE_EQ(g[2],a0*c2+a1*c1+a2*c0);
343 ASSERT_DOUBLE_EQ(g[3],a0*c3+a1*c2+a2*c1);
344 ASSERT_DOUBLE_EQ(g[4],a1*c3+a2*c2);
345 ASSERT_DOUBLE_EQ(g[5],a2*c3);
349 int main(
int argc,
char **argv){
350 ::testing::InitGoogleTest(&argc,argv);
351 return RUN_ALL_TESTS();
int main(int argc, char **argv)
void appendTerm(FieldT coeff)
Append new terms by pushing back coefficients.
virtual ~PolynomialTest()
TEST_F(PolynomialTest, constructor_default)
Polynomial & minus()
Flip the sign of all coefs.
Contains the definition for the abstract base class which will be used by different multiplication al...