Skip to content

Commit b38ef52

Browse files
committed
test: modify the layout of some codes
1 parent 958a190 commit b38ef52

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

source/module_base/test/complexarray_test.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,9 @@
7070
* - function point_mult()
7171
*/
7272

73-
74-
double prec_test = 1e-14;
7573
//compare two complex by using EXPECT_DOUBLE_EQ()
7674
void EXPECT_COMPLEX_EQUAL(const std::complex<double>& a,const std::complex<double>& b)
7775
{
78-
//EXPECT_NEAR(a.real(),b.real(),prec_test);
79-
//EXPECT_NEAR(a.imag(),b.imag(),prec_test);
8076
EXPECT_DOUBLE_EQ(a.real(),b.real());
8177
EXPECT_DOUBLE_EQ(a.imag(),b.imag());
8278
}
@@ -163,7 +159,7 @@ TEST_F(ComplexArray_test,operator_equal_ComplexArray)
163159
{
164160
a2 = com1;
165161
ModuleBase::ComplexArray b = a2;
166-
for ( int i = 0;i<a2.getSize();++i)
162+
for (int i = 0;i<a2.getSize();++i)
167163
{
168164
EXPECT_COMPLEX_EQUAL(b.ptr[i],a2.ptr[i]);
169165
}
@@ -238,7 +234,7 @@ TEST_F(ComplexArray_test,operator_multiply_double)
238234
{
239235
a2 = com1;
240236
c2 = a2 * 2.0;
241-
for ( int i = 0;i<a2.getSize();++i)
237+
for (int i = 0;i<a2.getSize();++i)
242238
{
243239
EXPECT_COMPLEX_EQUAL(c2.ptr[i],com1*2.0);
244240
}
@@ -248,7 +244,7 @@ TEST_F(ComplexArray_test,operator_multiply_complex)
248244
{
249245
a2 = com1;
250246
c2 = a2 * com2;
251-
for ( int i = 0;i<a2.getSize();++i)
247+
for (int i = 0;i<a2.getSize();++i)
252248
{
253249
EXPECT_COMPLEX_EQUAL(c2.ptr[i],com1*com2);
254250
}
@@ -258,7 +254,7 @@ TEST_F(ComplexArray_test,operator_multiply_equal_double)
258254
{
259255
a2 = com1;
260256
a2 *= 3.0;
261-
for ( int i = 0;i<a2.getSize();++i)
257+
for (int i = 0;i<a2.getSize();++i)
262258
{
263259
EXPECT_COMPLEX_EQUAL(a2.ptr[i],com1*3.0);
264260
}
@@ -268,7 +264,7 @@ TEST_F(ComplexArray_test,operator_multiply_equal_complex)
268264
{
269265
a2 = com1;
270266
a2 *= com2;
271-
for ( int i = 0;i<a2.getSize();++i)
267+
for (int i = 0;i<a2.getSize();++i)
272268
{
273269
EXPECT_COMPLEX_EQUAL(a2.ptr[i],com1*com2);
274270
}
@@ -278,8 +274,9 @@ TEST_F(ComplexArray_test,operator_multiply_equal_ComplexArray)
278274
{
279275
a2 = com1;
280276
b2 = com2;
277+
281278
a2 *= b2;
282-
for ( int i = 0;i<a2.getSize();++i)
279+
for (int i = 0;i<a2.getSize();++i)
283280
{
284281
EXPECT_COMPLEX_EQUAL(a2.ptr[i],com1*com2);
285282
}
@@ -378,7 +375,7 @@ TEST_F(ComplexArray_test,operator_double_multiply)
378375
{
379376
a2 = com1;
380377
c2 = 2.0 * a2 ;
381-
for ( int i = 0;i<a2.getSize();++i)
378+
for (int i = 0;i<a2.getSize();++i)
382379
{
383380
EXPECT_COMPLEX_EQUAL(c2.ptr[i],2.0 * com1);
384381
}
@@ -388,7 +385,7 @@ TEST_F(ComplexArray_test,operator_complex_multiply)
388385
{
389386
a2 = com1;
390387
c2 = com2 * a2 ;
391-
for ( int i = 0;i<a2.getSize();++i)
388+
for (int i = 0;i<a2.getSize();++i)
392389
{
393390
EXPECT_COMPLEX_EQUAL(c2.ptr[i],com2 * com1);
394391
}
@@ -428,7 +425,7 @@ TEST_F(ComplexArray_test,scale_accumulate_double)
428425
a2 = com1;
429426
b2 = com2;
430427
scale_accumulate(0.3,a2,b2);
431-
for ( int i = 0;i<b2.getSize();++i)
428+
for (int i = 0;i<b2.getSize();++i)
432429
{
433430
EXPECT_COMPLEX_EQUAL(b2.ptr[i],0.3*com1+com2);
434431
}
@@ -439,7 +436,7 @@ TEST_F(ComplexArray_test,scale_accumulate_complex)
439436
a2 = com1;
440437
b2 = com2;
441438
scale_accumulate(com3,a2,b2);
442-
for ( int i = 0;i<b2.getSize();++i)
439+
for (int i = 0;i<b2.getSize();++i)
443440
{
444441
EXPECT_COMPLEX_EQUAL(b2.ptr[i],com3*com1+com2);
445442
}
@@ -450,7 +447,7 @@ TEST_F(ComplexArray_test,scaled_sum)
450447
a2 = com1;
451448
b2 = com2;
452449
scaled_sum(0.3,a2,0.4,b2,c2);
453-
for ( int i = 0;i<c2.getSize();++i)
450+
for (int i = 0;i<c2.getSize();++i)
454451
{
455452
EXPECT_COMPLEX_EQUAL(c2.ptr[i],0.3*com1 + 0.4*com2);
456453
}
@@ -461,7 +458,7 @@ TEST_F(ComplexArray_test,point_mult)
461458
a2 = com1;
462459
b2 = com2;
463460
point_mult(a2,b2,c2);
464-
for ( int i = 0;i<c2.getSize();++i)
461+
for (int i = 0;i<c2.getSize();++i)
465462
{
466463
EXPECT_COMPLEX_EQUAL(c2.ptr[i],com1*com2);
467464
}

0 commit comments

Comments
 (0)