Commit afb52a3
source_basis/module_ao: orb_atomic_lm_test off the access hack, via getters plus one friend (#7953)
`orb_atomic_lm_test.cpp` reached into 17 private members of
`Numerical_Orbital_Lm` and called four of its private methods. Sixteen of those
members already have public accessors, so the macro comes off mostly by using
them: 138 sites now read through `get_psi()`, `getNr()`, `getRcut()` and the
rest. No PARAM is involved.
Two things needed more than a substitution:
- `psir` was the only array in the class without the vector accessor its
siblings all have. `Numerical_Orbital_Lm` exposes a systematic trio per array
-- `getX()` returning a pointer, `getX(i)` returning an element, `get_x()`
returning the vector -- and psir had only the first two, so `.psir.size()` and
`.psir.empty()` had no public route. Added the missing
`get_psir()`, completing the pattern rather than inventing an accessor for the
test.
- `cal_kradial`, `cal_kradial_sbpool`, `cal_rradial_sbpool` and `plot` are
private and are what four of the tests exist to exercise. These get
`friend class NumericalOrbitalLmTest;`, next to the `friend class
Numerical_Orbital;` the class already carries, plus four forwarding wrappers
on the fixture -- a TEST_F body lives in a derived class and does not inherit
friendship.
The substitution is uniform because the accessors return the member itself:
`get_psi()` yields `const std::vector<double>&`, so `.psi[i]`, `.psi.size()`,
`.psi.empty()` and bare `.psi` all keep working through it, and the scalar
getters return const references. Every site was rewritten mechanically and then
checked: no private member of the class is named in any TEST_F body any more.
No test expectation changed. Macro occurrences in this file go 1 -> 0; no
`#undef private` is added and no other file is touched.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 9958006 commit afb52a3
2 files changed
Lines changed: 156 additions & 146 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| |||
139 | 142 | | |
140 | 143 | | |
141 | 144 | | |
| 145 | + | |
142 | 146 | | |
143 | 147 | | |
144 | 148 | | |
| |||
0 commit comments