Skip to content

Return nil for negative child removal indices - #161

Open
bensynapse wants to merge 1 commit into
beevik:mainfrom
bensynapse:fix-negative-child-removal
Open

bensynapse wants to merge 1 commit into
beevik:mainfrom
bensynapse:fix-negative-child-removal

Conversation

@bensynapse

Copy link
Copy Markdown

I run Live Tennis API.

RemoveChildAt(-1) currently panics, although its documented contract returns nil when the index is out of bounds.

Check the lower bound before indexing the child slice. Add regressions for negative and upper bounds on empty elements and elements with several token types.
The tests check that invalid calls preserve child identity, order, parents, indices and serialized XML.

The native suite, race coverage, vet and build pass on Go 1.23.4 and 1.27.0 on Linux amd64.
Commands: go test -v ./..., go test -race -cover ./..., go vet ./... and go build -v ./....
All 12 new cases pass. Six negative index cases fail against the original source.

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.

1 participant