Commit 9958006
source_basis/module_ao: drop the access hack from two orbital tests, no production change (#7952)
`orb_nonlocal_test.cpp` and `orb_read_test.cpp` switched off access control for
their whole translation unit to reach members of `Numerical_Nonlocal` and
`LCAO_Orbitals` that mostly already have public getters. Neither file touches
PARAM, and neither needs anything added to a production header: the macro is
removed by using the accessors that exist, plus one fixture built through the
public API instead of by assignment.
Three distinct cases, and the second is the interesting one:
1. The member is used as a plain value. Read it through its getter --
`lcao_.kmesh` -> `lcao_.get_kmesh()` (4 sites), and the five assertions in
`SetTypeInfo` now read `nn.getLabel()`, `getType()`, `getLmax()`,
`get_rcut_max()`, `get_nproj()`. Those already compared against the fixture's
inputs, so they stay real checks.
2. The assertion *is* `EXPECT_EQ(obj.get_x(), obj.x)`. Substituting the getter
would turn it into `EXPECT_EQ(get_x(), get_x())` -- it cannot fail, and the
test would be silently gutted. These are re-anchored to the value the object
was given instead, which is what `orb_nonlocal_test` already did on one line
(`EXPECT_EQ(nn.get_rcut_max(), rcut_max_)`); the rest now match it.
In `LCAO_Orbitals::Getters`, seven of the twelve assertions covered private
members. `ntype` and `lmax` are passed straight into `Read_Orbitals`, so they
anchor to `ntype_` / `lmax_`. The other four are derived, and the production
formula is deliberately *not* restated in the test -- a test that recomputes
what it is checking passes even when the formula is wrong. They are asserted
as the concrete values this fixture implies, each with its provenance:
`kmesh` 1113 = int(sqrt(123)/0.01) + 4, `nchimax` 2 (H is 2s1p, O is 2s2p1d),
`lmax_d`/`nchimax_d` 2 from jle.orb, `rcutmax_Phi` 8 au (H 8 au, O 7 au).
Measured against the built test to confirm, and kmesh cross-checked by hand
against Read_Orbitals.
3. The test *wrote* a private member to build a fixture:
`nnl[i].rcut = 1.0` in `NumericalNonlocalTest::SetUp`. `Numerical_Nonlocal_Lm`
derives rcut from the last point of its radial mesh, so each projector is now
built through the public `set_NL_proj()` with a minimal three-point mesh whose
endpoint is the wanted rcut. That removes the write and additionally exercises
`set_NL_proj`, which no assertion in this file reached before.
`ecutwfc`, `dk`, `dR`, `Rmax` and `dr_uniform` are public members of
`LCAO_Orbitals` and never needed the macro; the four that compare against a
fixture input are anchored to it for consistency, and `dr_uniform` is left alone.
Macro occurrences in these two files go 2 -> 0. No `#undef private` is added, and
no file whose macro survives is touched.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 9cbcc0b commit 9958006
2 files changed
Lines changed: 57 additions & 32 deletions
Lines changed: 33 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | | - | |
7 | 5 | | |
8 | 6 | | |
9 | 7 | | |
| |||
54 | 52 | | |
55 | 53 | | |
56 | 54 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
62 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
63 | 77 | | |
64 | 78 | | |
65 | 79 | | |
| |||
72 | 86 | | |
73 | 87 | | |
74 | 88 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
80 | 94 | | |
81 | 95 | | |
82 | 96 | | |
83 | 97 | | |
84 | 98 | | |
85 | 99 | | |
86 | 100 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
91 | 108 | | |
92 | 109 | | |
93 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | | - | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
| |||
178 | 176 | | |
179 | 177 | | |
180 | 178 | | |
181 | | - | |
| 179 | + | |
182 | 180 | | |
183 | 181 | | |
184 | 182 | | |
| |||
226 | 224 | | |
227 | 225 | | |
228 | 226 | | |
229 | | - | |
| 227 | + | |
230 | 228 | | |
231 | 229 | | |
232 | 230 | | |
| |||
287 | 285 | | |
288 | 286 | | |
289 | 287 | | |
290 | | - | |
| 288 | + | |
291 | 289 | | |
292 | 290 | | |
293 | 291 | | |
| |||
307 | 305 | | |
308 | 306 | | |
309 | 307 | | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
320 | 314 | | |
321 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
322 | 330 | | |
323 | 331 | | |
324 | 332 | | |
| |||
0 commit comments