Repository navigation
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.
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(). |
eiriktsarpalis
left a comment
There was a problem hiding this comment.
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.