-
Notifications
You must be signed in to change notification settings - Fork 641
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
Add support unit tests for ConcurrentHashSet, #1117 #1128
base: master
Are you sure you want to change the base?
Conversation
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.
Thanks for the PR.
I have been considering phasing out the SystemTypesHelpers
class (or at least most of the extension methods in it), so ideally any new tests we add would not have any dependencies on those extension methods (.add()
, .contains()
, .size()
, etc.).
If we do keep them, they will definitely need a review. Some of the methods perform poorly or have better alternatives (.toString()
, removeAll()
, retainAll()
, and ToByteArray()
to name a few). The .append()
overloads are generally there to allow culture invariant numbers to be appended, since .NET doesn't have that built-in. However, I am adding optional parameters to allow passing format
and IFormatProvider
on OpenStringBuilder
in J2N. So, we should probably hold off on the review/removal of SystemTypesHelpers
until after J2N has a build with OpenStringBuilder
where those can be replaced directly by swapping in OpenStringBuilder
for StringBuilder
.
smallSet.add(objArray[i]); | ||
} | ||
// LUCENENET TODO: could port this class and all of the classes it uses | ||
// new Support_SetTest(new ConcurrentHashSet<object>(smallSet)) |
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.
Do note that some of these Support_
tests from Harmony have been ported in J2N. https://github.com/NightOwl888/J2N/blob/main/tests/NUnit/J2N.Tests/Collections/
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.
That code appears to be GPL licensed, based on the license in the test project (and that there is no other license listed in this file). Would that be an issue? How would I do the license header in that case?
But we could always leave as a future TODO to port those tests. This test class gives very good test coverage already without them.
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.
The Support_
classes were ported from Apache Harmony, so no issue with those:
https://github.com/apache/harmony/blob/trunk/classlib/support/src/test/java/tests/support/Support_SetTest.java
https://github.com/apache/harmony/blob/trunk/classlib/support/src/test/java/tests/support/Support_CollectionTest.java
The GPL license was put there because some of the test code is directly from the JDK and it is the most restrictive license. But we don't ship the test projects. J2N is made up from Apache 2.0 and MIT licenses and should all have headers, but I haven't gone through all of the test files to add license headers.
Add support unit tests for ConcurrentHashSet
Fixes #1117
Description
This ports tests from Harmony for
Collections.synchronizedSet
andConcurrentHashMap
and adapts them to ourConcurrentHashSet
.This also adds nullable reference type checking to ConcurrentHashSet, which exposed some nullability issues. Given that our current use of this type is for values that should never be null (or would otherwise throw an NRE upon use as null is not checked-for), this adds a generic type constraint of
notnull
to ensure that it cannot be used with nullable reference types. Work would need to be done (under proper unit test coverage) to make this null-friendly if that is needed in the future.