-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
test: add Missing unit tests for Grouping.Any #57550
Conversation
Tagging subscribers to this area: @eiriktsarpalis Issue DetailsFor 'IIListProvider''s logic: If you want to check whether it has values or not, ">0" is enough. Otherwise, according to the original logic, if the source is IIListProvider and the 'GetCount()' <0, it will go to 'e.MoveNext();'. This is a bit too duplicated.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @MaledongGit, and thank you for your contribution!
This will actually break the implementation.
The IListProvider.GetCount
method will return -1
if it cannot cheaply calculate the count, in which case we need to fall back to the default enumerator-based approach. This change will result in any IListProvider with O(n) count calculation being erroneously reported as being empty.
I'm seeing a few tests fail in CI, but none actually originate from System.Linq.Tests. This suggests a potential gap in our test coverage. @MaledongGit would you be interested in changing this into a PR that adds a test like that?
Thanks for your tips, and what you said is just what I feel strange about.... XD
Add into the 'tests' under System.LINQ folder ONLY? Is there anything class or if I should mock a class inherted from IIListProvider? |
@eiriktsarpalis: I'd be happy if I could help :) |
This is the file containing all Enumerable.Any tests: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Linq/tests/AnyTests.cs. Adding a test would require finding an
|
Sorry to misunderstand it, and I've changed my PR to add the missing unit tests for Grouping().Any(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @MaledongGit!
It's my fault, I should be responsible for it ;) |
Seeing there're some missing unit cases for the extension of Enumerable.GroupBy().Any(), here's the fix for it.