Skip to content

Commit ae3e9d1

Browse files
author
Zanthoxylum
committed
Refactor DFPT unit tests: consolidate ctor/dtor stubs into shared dfpt_test_mocks.cpp (mirror tmp_mocks.cpp convention); absorb dftu_test_support.cpp
1 parent a8185af commit ae3e9d1

9 files changed

Lines changed: 113 additions & 251 deletions

File tree

source/source_pw/module_dfpt/test/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,24 @@ AddTest(
1111
../../../source_cell/qlist.cpp
1212
../../../source_cell/reciprocal_grid.cpp
1313
../../../source_psi/psi.cpp
14-
# Plus_U_Base ctor/dtor support shim (see dftu_test_support.cpp).
15-
dftu_test_support.cpp
14+
# Shared ctor/dtor stubs for the cell/spepot/Plus_U link closures.
15+
dfpt_test_mocks.cpp
1616
)
1717

1818
AddTest(
1919
TARGET MODULE_DFPT_kq_basis_test
2020
LIBS parameter base device symmetry planewave
2121
SOURCES dfpt_kq_basis_test.cpp
2222
../dfpt_kq_basis.cpp
23+
dfpt_test_mocks.cpp
2324
)
2425

2526
AddTest(
2627
TARGET MODULE_DFPT_stern_test
2728
LIBS parameter base device symmetry
2829
SOURCES dfpt_stern_test.cpp
2930
../dfpt_stern.cpp
31+
dfpt_test_mocks.cpp
3032
)
3133

3234
AddTest(
@@ -46,7 +48,6 @@ AddTest(
4648
../../../source_cell/qlist.cpp
4749
../../../source_cell/reciprocal_grid.cpp
4850
../../../source_psi/psi.cpp
49-
# Plus_U support shim: lets the test construct a Plus_U without pulling
50-
# the LCAO-side DFT+U link closure (see dftu_test_support.cpp).
51-
dftu_test_support.cpp
51+
# Shared ctor/dtor stubs for the cell/spepot/charge/Plus_U closures.
52+
dfpt_test_mocks.cpp
5253
)

source/source_pw/module_dfpt/test/dfpt_pw_data_test.cpp

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,8 @@
1616
#include "source_pw/module_dfpt/dfpt_pw_data.h"
1717
#include "source_pw/module_pwdft/dftu_base.h"
1818

19-
pseudo::pseudo()
20-
{
21-
}
22-
pseudo::~pseudo()
23-
{
24-
}
25-
Atom::Atom()
26-
{
27-
}
28-
Atom::~Atom()
29-
{
30-
}
31-
Atom_pseudo::Atom_pseudo()
32-
{
33-
}
34-
Atom_pseudo::~Atom_pseudo()
35-
{
36-
}
37-
SepPot::SepPot() {}
38-
SepPot::~SepPot() {}
39-
UnitCell::UnitCell()
40-
{
41-
}
42-
UnitCell::~UnitCell()
43-
{
44-
}
45-
Magnetism::Magnetism()
46-
{
47-
}
48-
Magnetism::~Magnetism()
49-
{
50-
}
51-
Sep_Cell::Sep_Cell() noexcept {}
52-
Sep_Cell::~Sep_Cell() noexcept {}
19+
// ctor/dtor stubs for the cell/spepot link closures live in the shared
20+
// dfpt_test_mocks.cpp compiled into every DFPT test binary.
5321

5422
/************************************************
5523
* unit test of DFPT_PW_Data (Phase 4 wiring; B4

source/source_pw/module_dfpt/test/dfpt_pw_run_test.cpp

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,8 @@
1717
#include "source_pw/module_pwdft/dftu_base.h"
1818
#include "source_pw/module_dfpt/dfpt_pw.h"
1919

20-
pseudo::pseudo()
21-
{
22-
}
23-
pseudo::~pseudo()
24-
{
25-
}
26-
Atom::Atom()
27-
{
28-
}
29-
Atom::~Atom()
30-
{
31-
}
32-
Atom_pseudo::Atom_pseudo()
33-
{
34-
}
35-
Atom_pseudo::~Atom_pseudo()
36-
{
37-
}
38-
SepPot::SepPot() {}
39-
SepPot::~SepPot() {}
40-
UnitCell::UnitCell()
41-
{
42-
}
43-
UnitCell::~UnitCell()
44-
{
45-
}
46-
Magnetism::Magnetism()
47-
{
48-
}
49-
Magnetism::~Magnetism()
50-
{
51-
}
52-
Sep_Cell::Sep_Cell() noexcept {}
53-
Sep_Cell::~Sep_Cell() noexcept {}
54-
55-
Charge_Mixing::~Charge_Mixing() {}
20+
// ctor/dtor stubs for the cell/spepot/charge link closures live in the
21+
// shared dfpt_test_mocks.cpp compiled into every DFPT test binary.
5622

5723
/************************************************
5824
* unit test of DFPT_PW::run() (Phase 4 wiring)
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// ============================================================
2+
// Minimal test-support ctor/dtor stubs shared by all DFPT unit
3+
// test binaries (test/ and test_serial/), mirroring the
4+
// tmp_mocks.cpp convention of the other module test suites.
5+
//
6+
// In production these symbols live in full link closures the DFPT
7+
// tests do not want to pull in:
8+
// - cell/spepot/stru_fac/charge_mixing closures (via UnitCell),
9+
// - the pwdft DFT+U closure (Plus_U_Base, see the former
10+
// dftu_test_support.cpp this file absorbed).
11+
// The DFPT tests only need default-constructible objects, so the
12+
// empty definitions are replicated here once instead of in every
13+
// test translation unit. Keep the signatures in sync with the
14+
// production sources.
15+
// ============================================================
16+
17+
#include "source_cell/atom_pseudo.h"
18+
#include "source_cell/atom_spec.h"
19+
#include "source_cell/magnetism.h"
20+
#include "source_cell/pseudo.h"
21+
#include "source_cell/unitcell.h"
22+
#include "source_estate/module_charge/charge_mixing.h"
23+
#include "source_pw/module_pwdft/dftu_base.h"
24+
#include "source_pw/module_pwdft/stru_fac.h"
25+
26+
pseudo::pseudo()
27+
{
28+
}
29+
pseudo::~pseudo()
30+
{
31+
}
32+
Atom::Atom()
33+
{
34+
}
35+
Atom::~Atom()
36+
{
37+
}
38+
Atom_pseudo::Atom_pseudo()
39+
{
40+
}
41+
Atom_pseudo::~Atom_pseudo()
42+
{
43+
}
44+
SepPot::SepPot()
45+
{
46+
}
47+
SepPot::~SepPot()
48+
{
49+
}
50+
Sep_Cell::Sep_Cell() noexcept
51+
{
52+
}
53+
Sep_Cell::~Sep_Cell() noexcept
54+
{
55+
}
56+
UnitCell::UnitCell()
57+
{
58+
}
59+
UnitCell::~UnitCell()
60+
{
61+
}
62+
Magnetism::Magnetism()
63+
{
64+
}
65+
Magnetism::~Magnetism()
66+
{
67+
}
68+
69+
Structure_Factor::Structure_Factor()
70+
{
71+
}
72+
Structure_Factor::~Structure_Factor()
73+
{
74+
}
75+
76+
Charge_Mixing::~Charge_Mixing()
77+
{
78+
}
79+
80+
Plus_U_Base::Plus_U_Base()
81+
{
82+
}
83+
Plus_U_Base::~Plus_U_Base()
84+
{
85+
}

source/source_pw/module_dfpt/test/dftu_test_support.cpp

Lines changed: 0 additions & 20 deletions
This file was deleted.

source/source_pw/module_dfpt/test_serial/CMakeLists.txt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ AddTest(
3838
../../../source_cell/qlist.cpp
3939
../../../source_cell/reciprocal_grid.cpp
4040
../../../source_psi/psi.cpp
41-
# Plus_U test-support shim shared with the MPI-side dfpt tests.
42-
../test/dftu_test_support.cpp
41+
# Shared ctor/dtor stubs for the cell/spepot/Plus_U link closures
42+
# (see test/dfpt_test_mocks.cpp).
43+
../test/dfpt_test_mocks.cpp
4344
)
4445

4546
AddTest(
@@ -52,8 +53,9 @@ AddTest(
5253
../../../source_cell/qlist.cpp
5354
../../../source_cell/reciprocal_grid.cpp
5455
../../../source_psi/psi.cpp
55-
# Plus_U test-support shim shared with the MPI-side dfpt tests.
56-
../test/dftu_test_support.cpp
56+
# Shared ctor/dtor stubs for the cell/spepot/Plus_U link closures
57+
# (see test/dfpt_test_mocks.cpp).
58+
../test/dfpt_test_mocks.cpp
5759
)
5860

5961
AddTest(
@@ -67,8 +69,9 @@ AddTest(
6769
../../../source_cell/qlist.cpp
6870
../../../source_cell/reciprocal_grid.cpp
6971
../../../source_psi/psi.cpp
70-
# Plus_U test-support shim shared with the MPI-side dfpt tests.
71-
../test/dftu_test_support.cpp
72+
# Shared ctor/dtor stubs for the cell/spepot/Plus_U link closures
73+
# (see test/dfpt_test_mocks.cpp).
74+
../test/dfpt_test_mocks.cpp
7275
)
7376

7477
AddTest(
@@ -82,6 +85,7 @@ AddTest(
8285
../../../source_cell/qlist.cpp
8386
../../../source_cell/reciprocal_grid.cpp
8487
../../../source_psi/psi.cpp
85-
# Plus_U test-support shim shared with the MPI-side dfpt tests.
86-
../test/dftu_test_support.cpp
88+
# Shared ctor/dtor stubs for the cell/spepot/Plus_U link closures
89+
# (see test/dfpt_test_mocks.cpp).
90+
../test/dfpt_test_mocks.cpp
8791
)

source/source_pw/module_dfpt/test_serial/dfpt_pert_serial_test.cpp

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -28,56 +28,8 @@
2828
#include "source_pw/module_pwdft/dftu_base.h"
2929
#include "source_psi/psi.h"
3030

31-
// test-support ctor/dtor stubs (see test/dfpt_pw_run_test.cpp); the DFPT
32-
// serial test only needs default-constructible cell/sf objects.
33-
pseudo::pseudo()
34-
{
35-
}
36-
pseudo::~pseudo()
37-
{
38-
}
39-
Atom::Atom()
40-
{
41-
}
42-
Atom::~Atom()
43-
{
44-
}
45-
Atom_pseudo::Atom_pseudo()
46-
{
47-
}
48-
Atom_pseudo::~Atom_pseudo()
49-
{
50-
}
51-
SepPot::SepPot()
52-
{
53-
}
54-
SepPot::~SepPot()
55-
{
56-
}
57-
Sep_Cell::Sep_Cell() noexcept
58-
{
59-
}
60-
Sep_Cell::~Sep_Cell() noexcept
61-
{
62-
}
63-
UnitCell::UnitCell()
64-
{
65-
}
66-
UnitCell::~UnitCell()
67-
{
68-
}
69-
Magnetism::Magnetism()
70-
{
71-
}
72-
Magnetism::~Magnetism()
73-
{
74-
}
75-
Structure_Factor::Structure_Factor()
76-
{
77-
}
78-
Structure_Factor::~Structure_Factor()
79-
{
80-
}
31+
// ctor/dtor stubs for the cell/spepot/stru_fac link closures live in the
32+
// shared test/dfpt_test_mocks.cpp compiled into every DFPT test binary.
8133

8234
/************************************************
8335
* serial unit test of DFPT_Pert (C1)

source/source_pw/module_dfpt/test_serial/dfpt_phon_serial_test.cpp

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -28,55 +28,8 @@
2828
#include "source_base/vector3.h"
2929
#include "source_psi/psi.h"
3030

31-
// test-support ctor/dtor stubs (see dfpt_pert_serial_test.cpp)
32-
pseudo::pseudo()
33-
{
34-
}
35-
pseudo::~pseudo()
36-
{
37-
}
38-
Atom::Atom()
39-
{
40-
}
41-
Atom::~Atom()
42-
{
43-
}
44-
Atom_pseudo::Atom_pseudo()
45-
{
46-
}
47-
Atom_pseudo::~Atom_pseudo()
48-
{
49-
}
50-
SepPot::SepPot()
51-
{
52-
}
53-
SepPot::~SepPot()
54-
{
55-
}
56-
Sep_Cell::Sep_Cell() noexcept
57-
{
58-
}
59-
Sep_Cell::~Sep_Cell() noexcept
60-
{
61-
}
62-
UnitCell::UnitCell()
63-
{
64-
}
65-
UnitCell::~UnitCell()
66-
{
67-
}
68-
Magnetism::Magnetism()
69-
{
70-
}
71-
Magnetism::~Magnetism()
72-
{
73-
}
74-
Structure_Factor::Structure_Factor()
75-
{
76-
}
77-
Structure_Factor::~Structure_Factor()
78-
{
79-
}
31+
// ctor/dtor stubs for the cell/spepot/stru_fac link closures live in the
32+
// shared test/dfpt_test_mocks.cpp compiled into every DFPT test binary.
8033

8134
/************************************************
8235
* serial unit test of DFPT_Phon (C5)

0 commit comments

Comments
 (0)