Skip to content

Commit 1fe4b5d

Browse files
committed
test : modify google test
scope : test*.cpp utest.h utest.cpp
1 parent e51fe84 commit 1fe4b5d

22 files changed

+156
-124
lines changed

source/module_pw/pw_basis.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
namespace ModulePW
1111
{
1212

13-
//
14-
//A class which can convert a function of "r" to the corresponding linear
15-
// superposition of plane waves (real space to reciprocal space)
16-
// or convert a linear superposition of plane waves to the function
17-
// of "r" (reciprocal to real).
18-
//plane waves: <r|g>=1/sqrt(V) * exp(igr)
19-
// f(r) = 1/sqrt(V) * \sum_g{c(g)*exp(igr)}
20-
//
13+
///
14+
/// A class which can convert a function of "r" to the corresponding linear
15+
/// superposition of plane waves (real space to reciprocal space)
16+
/// or convert a linear superposition of plane waves to the function
17+
/// of "r" (reciprocal to real).
18+
/// plane waves: <r|g>=1/sqrt(V) * exp(igr)
19+
/// f(r) = 1/sqrt(V) * \sum_g{c(g)*exp(igr)}
20+
///
2121
class PW_Basis
2222
{
2323

source/module_pw/pw_basis_k.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
namespace ModulePW
66
{
77

8-
//
9-
//Special pw_basis class.
10-
//It includes different k-points
11-
//plane waves: <r|g,k>=1/sqrt(V) * exp(i(k+g)r)
12-
//
8+
///
9+
/// Special pw_basis class.
10+
/// It includes different k-points
11+
/// plane waves: <r|g,k>=1/sqrt(V) * exp(i(k+g)r)
12+
///
1313
class PW_Basis_K : public PW_Basis
1414
{
1515

File renamed without changes.
File renamed without changes.
File renamed without changes.

source/module_pw/unittest/test1-1.cpp renamed to source/module_pw/test/test1-1.cpp

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,27 @@
11
#include "../pw_basis.h"
2-
#include "../../src_parallel/parallel_global.h"
32
#ifdef __MPI
43
#include "test_tool.h"
4+
#include "../../src_parallel/parallel_global.h"
55
#include "mpi.h"
66
#endif
7-
#include "../../module_base/timer.h"
87
#include "../../module_base/global_function.h"
8+
#include "gtest/gtest.h"
9+
extern int nproc_in_pool,rank_in_pool;
910

10-
int main(int argc,char **argv)
11+
TEST(PWTEST,test1_1)
1112
{
13+
//--------------------------------------------------
1214
ModuleBase::Matrix3 latvec(1,0,0,0,1,0,0,0,1);
1315
bool gamma_only = true;
1416
double ecut = 100;
1517
double lat0 = 1;
16-
int nproc, myrank;
17-
int nproc_in_pool, npool, mypool, rank_in_pool;
18-
npool = 1;
19-
#ifdef __MPI
20-
setupmpi(argc,argv,nproc, myrank);
21-
divide_pools(nproc, myrank, nproc_in_pool, npool, mypool, rank_in_pool);
22-
#else
23-
nproc = nproc_in_pool = npool = 1;
24-
myrank = mypool = rank_in_pool = 0;
25-
#endif
26-
27-
ModuleBase::timer::start();
28-
2918
int distribution_type = 1;
19+
//--------------------------------------------------
20+
3021
ModulePW::PW_Basis pwtest;
3122

3223
pwtest.initgrids(lat0, latvec, ecut);
33-
pwtest.initparameters(gamma_only, ecut, nproc, rank_in_pool, distribution_type);
24+
pwtest.initparameters(gamma_only, ecut, nproc_in_pool, rank_in_pool, distribution_type);
3425
pwtest.distribute_r();
3526
pwtest.distribute_g();
3627

@@ -41,6 +32,7 @@ int main(int argc,char **argv)
4132
#else
4233
tot_npw = pwtest.npw;
4334
#endif
35+
4436
for (int ip = 0; ip < nproc; ip++)
4537
{
4638
#ifdef __MPI
@@ -95,10 +87,4 @@ int main(int argc,char **argv)
9587
std::cout << "\n";
9688
}
9789
}
98-
if(rank_in_pool==0) ModuleBase::timer::finish(GlobalV::ofs_running, true);
99-
#ifdef __MPI
100-
finishmpi();
101-
#endif
102-
103-
return 0;
10490
}

source/module_pw/unittest/test1-2.cpp renamed to source/module_pw/test/test1-2.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
#endif
1010
#include "../../module_base/constants.h"
1111
#include "../../module_base/global_function.h"
12-
#include <iomanip>
13-
#include "gtest/gtest.h"
14-
extern int nproc_in_pool,rank_in_pool;
12+
#include "utest.h"
1513

1614
using namespace std;
17-
TEST(PWTEST,test1_2)
15+
TEST_F(PWTEST,test1_2)
1816
{
17+
cout<<"dividemthd 1, gamma_only: off, double precision"<<endl;
1918
ModulePW::PW_Basis pwtest;
2019
ModuleBase::Matrix3 latvec;
2120
int nx,ny,nz; //f*G
@@ -28,12 +27,13 @@ TEST(PWTEST,test1_2)
2827
latvec = la;
2928
wfcecut = 10;
3029
gamma_only = false;
30+
int distribution_type = 1;
3131
//--------------------------------------------------
3232

3333
//init
3434
pwtest.initgrids(lat0,latvec,wfcecut);
3535
//pwtest.initgrids(lat0,latvec,5,7,7);
36-
pwtest.initparameters(gamma_only,wfcecut,nproc_in_pool,rank_in_pool,1);
36+
pwtest.initparameters(gamma_only,wfcecut,nproc_in_pool,rank_in_pool,distribution_type);
3737
pwtest.setuptransform();
3838
pwtest.collect_local_pw();
3939

source/module_pw/unittest/test1-2f.cpp renamed to source/module_pw/test/test1-2f.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
#endif
1010
#include "../../module_base/constants.h"
1111
#include "../../module_base/global_function.h"
12-
#include <iomanip>
13-
#include "gtest/gtest.h"
14-
extern int nproc_in_pool,rank_in_pool;
12+
#include "utest.h"
1513

1614
using namespace std;
17-
TEST(PWTEST,test1_2f)
15+
TEST_F(PWTEST,test1_2f)
1816
{
17+
cout<<"dividemthd 1, gamma_only: off, float precision"<<endl;
1918
ModulePW::PW_Basis pwtest;
2019
ModuleBase::Matrix3 latvec;
2120
int nx,ny,nz; //f*G
@@ -28,12 +27,13 @@ TEST(PWTEST,test1_2f)
2827
latvec = la;
2928
wfcecut = 10;
3029
gamma_only = false;
30+
int distribution_type = 1;
3131
//--------------------------------------------------
3232

3333
//init
3434
pwtest.initgrids(lat0,latvec,wfcecut);
3535
//pwtest.initgrids(lat0,latvec,5,7,7);
36-
pwtest.initparameters(gamma_only,wfcecut,nproc_in_pool,rank_in_pool,1);
36+
pwtest.initparameters(gamma_only,wfcecut,nproc_in_pool,rank_in_pool,distribution_type);
3737
pwtest.setuptransform();
3838
pwtest.collect_local_pw();
3939

source/module_pw/unittest/test1-3.cpp renamed to source/module_pw/test/test1-3.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
#endif
1010
#include "../../module_base/constants.h"
1111
#include "../../module_base/global_function.h"
12-
#include <iomanip>
13-
#include "gtest/gtest.h"
14-
extern int nproc_in_pool,rank_in_pool;
12+
#include "utest.h"
1513

1614
using namespace std;
17-
TEST(PWTEST,test1_3)
15+
TEST_F(PWTEST,test1_3)
1816
{
17+
cout<<"dividemthd 1, gamma_only: on, double precision"<<endl;
1918
ModulePW::PW_Basis pwtest;
2019
ModuleBase::Matrix3 latvec;
2120
int nx,ny,nz; //f*G
@@ -28,12 +27,13 @@ TEST(PWTEST,test1_3)
2827
latvec = la;
2928
wfcecut = 20;
3029
gamma_only = true;
30+
int distribution_type = 1;
3131
//--------------------------------------------------
3232

3333
//init
3434
pwtest.initgrids(lat0,latvec,1.5*wfcecut);
3535
//pwtest.initgrids(lat0,latvec,5,7,7);
36-
pwtest.initparameters(gamma_only,wfcecut,nproc_in_pool,rank_in_pool,1);
36+
pwtest.initparameters(gamma_only,wfcecut,nproc_in_pool,rank_in_pool,distribution_type);
3737
pwtest.setuptransform();
3838
pwtest.collect_local_pw();
3939

source/module_pw/unittest/test1-3f.cpp renamed to source/module_pw/test/test1-3f.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
#endif
1010
#include "../../module_base/constants.h"
1111
#include "../../module_base/global_function.h"
12-
#include <iomanip>
13-
#include "gtest/gtest.h"
14-
extern int nproc_in_pool,rank_in_pool;
12+
#include "utest.h"
1513

1614
using namespace std;
17-
TEST(PWTEST,test1_3f)
15+
TEST_F(PWTEST,test1_3f)
1816
{
17+
cout<<"dividemthd 1, gamma_only: on, float precision"<<endl;
1918
ModulePW::PW_Basis pwtest;
2019
ModuleBase::Matrix3 latvec;
2120
int nx,ny,nz; //f*G
@@ -28,12 +27,13 @@ TEST(PWTEST,test1_3f)
2827
latvec = la;
2928
wfcecut = 20;
3029
gamma_only = true;
30+
int distribution_type = 1;
3131
//--------------------------------------------------
3232

3333
//init
3434
pwtest.initgrids(lat0,latvec,1.5*wfcecut);
3535
//pwtest.initgrids(lat0,latvec,5,7,7);
36-
pwtest.initparameters(gamma_only,wfcecut,nproc_in_pool,rank_in_pool,1);
36+
pwtest.initparameters(gamma_only,wfcecut,nproc_in_pool,rank_in_pool,distribution_type);
3737
pwtest.setuptransform();
3838
pwtest.collect_local_pw();
3939

0 commit comments

Comments
 (0)