Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arrays value types in a zero-initialized state are considered empty #1126

merged 2 commits into from Jun 20, 2022


Copy link


With this pull request, arrays value types in a zero-initialized state are considered empty.
Before that, only the zero-length arrays were considered empty.
The new behavior is backward compatible with the existing currently test coverage.


  • added test cases for assert.Empty with array value types.
  • added test cases for assert.NotEmpty with array value types.
  • Adjust implementation according to the new test cases
  • minor refactoring


When I was reading the code source for learning purposes.
I discovered by chance that the assert.isEmpty / case reflect.Array code part doesn't have coverage.

assert.Empty(t, [1]int{})
assert.NotEmpty(t, [1]int{42})

Related issues

I'm not aware of any, but I didn't deeply check through the issues.

Copy link
Contributor Author

@glesica, when you have time, can you perhaps take a look at the change? : )

Copy link
Contributor Author

Any news on reviewing this PR?

Copy link

@boyan-soubachov boyan-soubachov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Thank you for your contribution :)

@boyan-soubachov boyan-soubachov merged commit 840cb80 into stretchr:master Jun 20, 2022
Copy link
Contributor Author

yay, I'm happy I was able to contribute to the project. :)))

Copy link

funvit commented Dec 14, 2022

Note: uuid.Nil from now works as expected with assert.Empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants