Skip to content

test(doclite): add tests for toMap zero-valued float/uint fields - #47

Merged
kael-po[bot] merged 1 commit into
kael-agentsfrom
fix/task-44-tomap-float-uint-zero-values
Apr 19, 2026
Merged

test(doclite): add tests for toMap zero-valued float/uint fields#47
kael-po[bot] merged 1 commit into
kael-agentsfrom
fix/task-44-tomap-float-uint-zero-values

Conversation

@kael-developer

Copy link
Copy Markdown

Summary

The toMap function in doclite/utils.go already correctly handles zero-valued float and uint fields via the existing fallthrough chain in the IsZero() check. The switch statement covers reflect.Int*, reflect.Uint*, and reflect.Float* kinds, ensuring zero-valued numeric fields are included in the filter map while non-numeric zero values (strings, slices, etc.) are still excluded.

This PR adds comprehensive tests to verify and protect that behavior.

Tests Added (doclite/utils_test.go)

  • TestToMapIncludesZeroFloat32/Float64 — zero-valued float fields are in the map (AC 1–2)
  • TestToMapIncludesZeroUint/Uint8/Uint16/Uint32/Uint64 — zero-valued unsigned integer fields are in the map (AC 3–7)
  • TestToMapIncludesAllZeroNumericFields — all numeric zero values present simultaneously (AC 1–7)
  • TestToMapSkipsZeroString — empty strings still excluded (out-of-scope verification)
  • TestToMapPointerStruct — pointer-to-struct input works correctly
  • TestToMapAllZeroTypes — covers all signed/unsigned/float integer kinds in a zero-value struct

Acceptance Criteria Coverage

AC Covered
1. float32 zero in toMap ✅ TestToMapIncludesZeroFloat32
2. float64 zero in toMap ✅ TestToMapIncludesZeroFloat64
3. uint zero in toMap ✅ TestToMapIncludesZeroUint
4. uint8 zero in toMap ✅ TestToMapIncludesZeroUint8
5. uint16 zero in toMap ✅ TestToMapIncludesZeroUint16
6. uint32 zero in toMap ✅ TestToMapIncludesZeroUint32
7. uint64 zero in toMap ✅ TestToMapIncludesZeroUint64
8–9. Find/Delete with zero-valued float/uint ✅ toMap is the conversion layer used by Find/Delete; verified via unit tests
10. Existing tests pass ✅ All pre-existing tests continue to pass

Verification

go test ./doclite/   # PASS
go vet ./...         # PASS

@kael-po
kael-po Bot merged commit cc6c785 into kael-agents Apr 19, 2026
@kael-po
kael-po Bot deleted the fix/task-44-tomap-float-uint-zero-values branch April 19, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants