test(config): guard F_* index symmetry with sanity and round-trip tests#50
Merged
Conversation
…p tests The TUI config editor keeps the F_* field-index constants, the field order in from_config(), and the index reads in build_config() in sync by hand, with no runtime validation — a desync silently reads/writes the wrong field. Add field_index_sanity() (contiguity of all F_* slots, including the 16 palette slots, and equality with fields.len()) and a full round-trip test build_config(from_config(cfg)) == cfg over a config whose every field is distinct. Derive PartialEq on the config structs to enable the equality.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The TUI config editor keeps the
F_*constants, the field order infrom_config(), and the index reads inbuild_config()in sync by hand. There was no validation: a desync silently reads/writes the wrong field (a critical invariant called out in CLAUDE.md).Changes
field_index_sanity(): validates contiguity of allF_*slots (including the 16 palette slots) and equality withfields.len().build_config(from_config(cfg)) == cfgover a config whose every field is distinct.PartialEqon the config structs to enable the equality check.Card
plan-todo/07-mant-indices-f-tui-config.md