Skip to content

Fix unreachable error-type assertions in size-check tests - #4

Merged
schultz-is merged 1 commit into
trunkfrom
fix/test-error-assertions
Aug 3, 2026
Merged

Fix unreachable error-type assertions in size-check tests#4
schultz-is merged 1 commit into
trunkfrom
fix/test-error-assertions

Conversation

@schultz-is

Copy link
Copy Markdown
Owner

The errors.Is checks in the key/tweak size-validation subtests were nested inside the "if err == nil" branch and placed after t.Fatal, making them dead code. As a result the tests only verified that an error was returned, never that it was the correct type. Move each assertion out so it runs against the returned (non-nil) error.

Also change TweakSizeError to be returned as a value (TweakSizeError{}) rather than via new() (a pointer), consistent with KeySizeError. This is required for errors.Is to match: two distinct *TweakSizeError pointers are never ==, so the now-live tweak assertions would otherwise always fail.

The errors.Is checks in the key/tweak size-validation subtests were nested
inside the "if err == nil" branch and placed after t.Fatal, making them dead
code. As a result the tests only verified that an error was returned, never
that it was the correct type. Move each assertion out so it runs against the
returned (non-nil) error.

Also change TweakSizeError to be returned as a value (TweakSizeError{}) rather
than via new() (a pointer), consistent with KeySizeError. This is required for
errors.Is to match: two distinct *TweakSizeError pointers are never ==, so the
now-live tweak assertions would otherwise always fail.
@schultz-is
schultz-is merged commit b469d13 into trunk Aug 3, 2026
5 checks passed
@schultz-is
schultz-is deleted the fix/test-error-assertions branch August 3, 2026 00:58
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