6767* - function dot()
6868* - function scale_accumulate()
6969* - function scaled_sum()
70- * - fucntion point_mult()
70+ * - function point_mult()
7171*/
7272
7373
7474double prec_test = 1e-14 ;
75- // compare two complex by using EXPECT_NEAR ()
76- void EXPECT_COMPLEXD (const std::complex <double >& a,const std::complex <double >& b)
75+ // compare two complex by using EXPECT_DOUBLE_EQ ()
76+ void EXPECT_COMPLEX_EQUAL (const std::complex <double >& a,const std::complex <double >& b)
7777{
78- EXPECT_NEAR (a.real (),b.real (),prec_test);
79- EXPECT_NEAR (a.imag (),b.imag (),prec_test);
78+ // EXPECT_NEAR(a.real(),b.real(),prec_test);
79+ // EXPECT_NEAR(a.imag(),b.imag(),prec_test);
80+ EXPECT_DOUBLE_EQ (a.real (),b.real ());
81+ EXPECT_DOUBLE_EQ (a.imag (),b.imag ());
8082}
8183
8284class ComplexArray_test : public testing ::Test
@@ -136,7 +138,7 @@ TEST(ComplexArray, constructor_copy_test)
136138
137139}
138140
139- TEST (ComplexArray, construction_rvalue_test )
141+ TEST (ComplexArray, constructor_rvalue_test )
140142{
141143 ModuleBase::ComplexArray b (ModuleBase::ComplexArray (1 ,2 ,3 ,4 ));
142144 ASSERT_EQ (b.getSize (),24 );
@@ -152,7 +154,7 @@ TEST_F(ComplexArray_test,operator_equal_complex)
152154 a2 = com1;
153155 for (int i = 0 ;i<a2.getSize ();++i)
154156 {
155- EXPECT_COMPLEXD (a2.ptr [i],com1);
157+ EXPECT_COMPLEX_EQUAL (a2.ptr [i],com1);
156158 }
157159}
158160
@@ -163,7 +165,7 @@ TEST_F(ComplexArray_test,operator_equal_ComplexArray)
163165 ModuleBase::ComplexArray b = a2;
164166 for ( int i = 0 ;i<a2.getSize ();++i)
165167 {
166- EXPECT_COMPLEXD (b.ptr [i],a2.ptr [i]);
168+ EXPECT_COMPLEX_EQUAL (b.ptr [i],a2.ptr [i]);
167169 }
168170}
169171
@@ -174,7 +176,7 @@ TEST_F(ComplexArray_test,operator_equal_ComplexArray_rvalue)
174176
175177 for (int i = 0 ;i<a2.getSize ();++i)
176178 {
177- EXPECT_COMPLEXD (b.ptr [i],com1);
179+ EXPECT_COMPLEX_EQUAL (b.ptr [i],com1);
178180 }
179181
180182}
@@ -186,7 +188,7 @@ TEST_F(ComplexArray_test,operator_plus)
186188 c2 = a2 + b2;
187189 for (int i = 0 ;i<a2.getSize ();++i)
188190 {
189- EXPECT_COMPLEXD (c2.ptr [i],(com1+com2));
191+ EXPECT_COMPLEX_EQUAL (c2.ptr [i],(com1+com2));
190192 }
191193 EXPECT_DEATH (a2+a4," " );
192194 // EXPECT_DEATH(a2+d2,"");
@@ -199,7 +201,7 @@ TEST_F(ComplexArray_test,operator_plus_equal)
199201 a2 += b2;
200202 for (int i = 0 ;i<a2.getSize ();++i)
201203 {
202- EXPECT_COMPLEXD (a2.ptr [i],(com1+com2));
204+ EXPECT_COMPLEX_EQUAL (a2.ptr [i],(com1+com2));
203205 }
204206 EXPECT_DEATH (a2+=a4," " );
205207 // EXPECT_DEATH(a2+=d2,"");
@@ -212,7 +214,7 @@ TEST_F(ComplexArray_test,operator_minus)
212214 c2 = a2 - b2;
213215 for (int i = 0 ;i<a2.getSize ();++i)
214216 {
215- EXPECT_COMPLEXD (c2.ptr [i],(com1-com2));
217+ EXPECT_COMPLEX_EQUAL (c2.ptr [i],(com1-com2));
216218 }
217219 EXPECT_DEATH (a2-a4," " );
218220 // EXPECT_DEATH(a2-d2,"");
@@ -225,7 +227,7 @@ TEST_F(ComplexArray_test,operator_minus_equal)
225227 a2 -= b2;
226228 for (int i = 0 ;i<a2.getSize ();++i)
227229 {
228- EXPECT_COMPLEXD (a2.ptr [i],(com1-com2));
230+ EXPECT_COMPLEX_EQUAL (a2.ptr [i],(com1-com2));
229231 }
230232 EXPECT_DEATH (a2-=a4," " );
231233 // EXPECT_DEATH(a2-=d2,"");
@@ -238,7 +240,7 @@ TEST_F(ComplexArray_test,operator_multiply_double)
238240 c2 = a2 * 2.0 ;
239241 for ( int i = 0 ;i<a2.getSize ();++i)
240242 {
241- EXPECT_COMPLEXD (c2.ptr [i],com1*2.0 );
243+ EXPECT_COMPLEX_EQUAL (c2.ptr [i],com1*2.0 );
242244 }
243245}
244246
@@ -248,7 +250,7 @@ TEST_F(ComplexArray_test,operator_multiply_complex)
248250 c2 = a2 * com2;
249251 for ( int i = 0 ;i<a2.getSize ();++i)
250252 {
251- EXPECT_COMPLEXD (c2.ptr [i],com1*com2);
253+ EXPECT_COMPLEX_EQUAL (c2.ptr [i],com1*com2);
252254 }
253255}
254256
@@ -258,7 +260,7 @@ TEST_F(ComplexArray_test,operator_multiply_equal_double)
258260 a2 *= 3.0 ;
259261 for ( int i = 0 ;i<a2.getSize ();++i)
260262 {
261- EXPECT_COMPLEXD (a2.ptr [i],com1*3.0 );
263+ EXPECT_COMPLEX_EQUAL (a2.ptr [i],com1*3.0 );
262264 }
263265}
264266
@@ -268,7 +270,7 @@ TEST_F(ComplexArray_test,operator_multiply_equal_complex)
268270 a2 *= com2;
269271 for ( int i = 0 ;i<a2.getSize ();++i)
270272 {
271- EXPECT_COMPLEXD (a2.ptr [i],com1*com2);
273+ EXPECT_COMPLEX_EQUAL (a2.ptr [i],com1*com2);
272274 }
273275}
274276
@@ -279,7 +281,7 @@ TEST_F(ComplexArray_test,operator_multiply_equal_ComplexArray)
279281 a2 *= b2;
280282 for ( int i = 0 ;i<a2.getSize ();++i)
281283 {
282- EXPECT_COMPLEXD (a2.ptr [i],com1*com2);
284+ EXPECT_COMPLEX_EQUAL (a2.ptr [i],com1*com2);
283285 }
284286
285287 EXPECT_DEATH (a2*=a4," " );
@@ -307,35 +309,35 @@ TEST_F(ComplexArray_test,operator_parentheses)
307309{
308310 a2 = com1;
309311 c2 = a2;
310- EXPECT_COMPLEXD (c2 (0 ,0 ,0 ,0 ), com1);
312+ EXPECT_COMPLEX_EQUAL (c2 (0 ,0 ,0 ,0 ), com1);
311313
312314 c2 (1 ,0 ,0 ,0 ) = com2;
313315 EXPECT_NE (c2,a2);
314316
315317 EXPECT_DEATH (a2 (1 ,1 ,1 ,0 )," " );
316318}
317319
318- TEST_F (ComplexArray_test,fuction_zero_out )
320+ TEST_F (ComplexArray_test,zero_out )
319321{
320322 a2 = com1;
321323 a2.zero_out ();
322324 for (int i=0 ;i<a2.getSize ();++i)
323325 {
324- EXPECT_COMPLEXD (a2.ptr [i],comzero);
326+ EXPECT_COMPLEX_EQUAL (a2.ptr [i],comzero);
325327 }
326328}
327329
328- TEST_F (ComplexArray_test,fuction_negate )
330+ TEST_F (ComplexArray_test,negate )
329331{
330332 a2 = com1;
331333 a2.negate ();
332334 for (int i=0 ;i<a2.getSize ();++i)
333335 {
334- EXPECT_COMPLEXD (a2.ptr [i],com1*-1.0 );
336+ EXPECT_COMPLEX_EQUAL (a2.ptr [i],com1*-1.0 );
335337 }
336338}
337339
338- TEST (ComplexArray,fuction_randomize )
340+ TEST (ComplexArray,randomize )
339341{
340342 ModuleBase::ComplexArray a (10 ,10 ,10 ,10 );
341343 a.randomize ();
@@ -355,7 +357,7 @@ TEST(ComplexArray,fuction_randomize)
355357
356358}
357359
358- TEST (ComplexArray,fuction_getBoundSize )
360+ TEST (ComplexArray,getBoundSize )
359361{
360362 ModuleBase::ComplexArray a (1 ,2 ,3 ,4 );
361363 EXPECT_EQ (a.getSize (),24 );
@@ -366,7 +368,7 @@ TEST(ComplexArray,fuction_getBoundSize)
366368}
367369
368370
369- TEST_F (ComplexArray_test,fuction_create )
371+ TEST_F (ComplexArray_test,create )
370372{
371373 a2.create (2 ,3 ,4 ,5 );
372374 EXPECT_EQ (a2.getSize (),120 );
@@ -378,7 +380,7 @@ TEST_F(ComplexArray_test,operator_double_multiply)
378380 c2 = 2.0 * a2 ;
379381 for ( int i = 0 ;i<a2.getSize ();++i)
380382 {
381- EXPECT_COMPLEXD (c2.ptr [i],2.0 * com1);
383+ EXPECT_COMPLEX_EQUAL (c2.ptr [i],2.0 * com1);
382384 }
383385}
384386
@@ -388,11 +390,11 @@ TEST_F(ComplexArray_test,operator_complex_multiply)
388390 c2 = com2 * a2 ;
389391 for ( int i = 0 ;i<a2.getSize ();++i)
390392 {
391- EXPECT_COMPLEXD (c2.ptr [i],com2 * com1);
393+ EXPECT_COMPLEX_EQUAL (c2.ptr [i],com2 * com1);
392394 }
393395}
394396
395- TEST (ComplexArray,function_abs2 )
397+ TEST (ComplexArray,abs2 )
396398{
397399 ModuleBase::ComplexArray a (2 ,2 ,1 ,1 );
398400 a (0 ,0 ,0 ,0 ) = std::complex <double >{0.0 ,0.0 };
@@ -402,7 +404,7 @@ TEST(ComplexArray,function_abs2)
402404 EXPECT_DOUBLE_EQ (abs2 (a),28.0 );
403405}
404406
405- TEST (ComplexArray,function_dot )
407+ TEST (ComplexArray,dot )
406408{
407409 ModuleBase::ComplexArray a (2 ,2 ,1 ,1 );
408410 a (0 ,0 ,0 ,0 ) = std::complex <double >{0.0 ,1.0 };
@@ -417,50 +419,50 @@ TEST(ComplexArray,function_dot)
417419 b (1 ,1 ,0 ,0 ) = std::complex <double >{4.0 ,-3.0 };
418420 std::complex <double > expectab {8.0 ,-32.0 };
419421 std::complex <double > expectba {8.0 ,32.0 };
420- EXPECT_COMPLEXD (dot (a,b),expectab);
421- EXPECT_COMPLEXD (dot (b,a),expectba);
422+ EXPECT_COMPLEX_EQUAL (dot (a,b),expectab);
423+ EXPECT_COMPLEX_EQUAL (dot (b,a),expectba);
422424}
423425
424- TEST_F (ComplexArray_test,function_scale_accumulate_double )
426+ TEST_F (ComplexArray_test,scale_accumulate_double )
425427{
426428 a2 = com1;
427429 b2 = com2;
428430 scale_accumulate (0.3 ,a2,b2);
429431 for ( int i = 0 ;i<b2.getSize ();++i)
430432 {
431- EXPECT_COMPLEXD (b2.ptr [i],0.3 *com1+com2);
433+ EXPECT_COMPLEX_EQUAL (b2.ptr [i],0.3 *com1+com2);
432434 }
433435}
434436
435- TEST_F (ComplexArray_test,function_scale_accumulate_complex )
437+ TEST_F (ComplexArray_test,scale_accumulate_complex )
436438{
437439 a2 = com1;
438440 b2 = com2;
439441 scale_accumulate (com3,a2,b2);
440442 for ( int i = 0 ;i<b2.getSize ();++i)
441443 {
442- EXPECT_COMPLEXD (b2.ptr [i],com3*com1+com2);
444+ EXPECT_COMPLEX_EQUAL (b2.ptr [i],com3*com1+com2);
443445 }
444446}
445447
446- TEST_F (ComplexArray_test,function_scaled_sum )
448+ TEST_F (ComplexArray_test,scaled_sum )
447449{
448450 a2 = com1;
449451 b2 = com2;
450452 scaled_sum (0.3 ,a2,0.4 ,b2,c2);
451453 for ( int i = 0 ;i<c2.getSize ();++i)
452454 {
453- EXPECT_COMPLEXD (c2.ptr [i],0.3 *com1 + 0.4 *com2);
455+ EXPECT_COMPLEX_EQUAL (c2.ptr [i],0.3 *com1 + 0.4 *com2);
454456 }
455457}
456458
457- TEST_F (ComplexArray_test,function_point_mult )
459+ TEST_F (ComplexArray_test,point_mult )
458460{
459461 a2 = com1;
460462 b2 = com2;
461463 point_mult (a2,b2,c2);
462464 for ( int i = 0 ;i<c2.getSize ();++i)
463465 {
464- EXPECT_COMPLEXD (c2.ptr [i],com1*com2);
466+ EXPECT_COMPLEX_EQUAL (c2.ptr [i],com1*com2);
465467 }
466468}
0 commit comments