Commit 0b8770e
authored
test(network): fold onto carbide-test-support + enumerate cases to raise coverage (#2538)
## Description
The `network` crate tests for MAC formatting, IP prefixes, prefix sets,
address families, and VPC virtualization were comprised of number of
various assertions.
This folds them onto `carbide-test-support` based `Case`/`Check` tables
and then enumerates the input variants each pure function accepts and
rejects every separator and boundary length for MAC parsing, both Ok and
Err arms for prefix and family conversions, membership and aggregation
edges for IpSet, and every enum variant for the virtualization helpers.
The dense per-row enumeration is what moves the numbers.
Enumerating the prefix surface also surfaced a real bug: Ipv6 bifurcate
built its midpoint bit mask from a 64-bit literal
(0x8000_0000_0000_0000), so for a v6 prefix it flipped a bit 64
positions too low and returned the wrong sibling (2001:db8::8000:0/33
instead of 2001:db8:8000::/33). Widening the literal to the full 128-bit
top bit fixes it; the v4 path was already correct.
- `base_mac` / lib: enumerated MAC parse/format/serde over separators,
boundary lengths, and the sanitize-and-rewrite path.
- `ip`: enumerated prefix
from_str/TryFrom/contains/Ord/bifurcate/aggregate and the address-family
helpers; fixed the v6 bifurcate sibling bug above.
- `virtualization`: enumerated the FNN/L2 SVI and dual-stack helpers
across every variant, and round-tripped the sqlx `Encode`/`Decode` impls
through a real Postgres connection with `check_cases_async` and the
shared `sqlx_test` harness.
```
┌──────────┬─────────┬─────────┐
│ Metric │ Before │ After │
├──────────┼─────────┼─────────┤
│ Region │ 78.78% │ 93.91% │
│ Function │ 71.78% │ 93.10% │
│ Line │ 73.64% │ 96.82% │
└──────────┴─────────┴─────────┘
```
The sqlx `Encode`/`Decode` impls are now exercised by a real Postgres
round-trip — `carbide-test-support`'s async runner driving the shared
`sqlx_test` harness — so the table-driven approach reaches the database
codec too. What's left is mostly defensive match arms.
All tests pass and clippy is clean.
Signed-off-by: Chet Nichols III <chetn@nvidia.com>
## Type of Change
<!-- Check one that best describes this PR -->
- [ ] **Add** - New feature or capability
- [ ] **Change** - Changes in existing functionality
- [ ] **Fix** - Bug fixes
- [ ] **Remove** - Removed features or deprecated functionality
- [x] **Internal** - Internal changes (refactoring, tests, docs, etc.)
## Related Issues (Optional)
<!-- If applicable, provide GitHub Issue. -->
## Breaking Changes
- [ ] This PR contains breaking changes
<!-- If checked above, describe the breaking changes and migration steps
-->
## Testing
<!-- How was this tested? Check all that apply -->
- [x] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
- [ ] No testing required (docs, internal refactor, etc.)
## Additional Notes
<!-- Any additional context, deployment notes, or reviewer guidance -->
Signed-off-by: Chet Nichols III <chetn@nvidia.com>1 parent 794eea3 commit 0b8770e
7 files changed
Lines changed: 2421 additions & 320 deletions
File tree
- crates/network
- src
- ip
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
53 | 56 | | |
| 57 | + | |
54 | 58 | | |
55 | 59 | | |
56 | 60 | | |
0 commit comments