-
Notifications
You must be signed in to change notification settings - Fork 909
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix improper negative key generation and update assertions in tests (#…
…4332) Fix #2077 By the way, I have been tested, negative number will fail. ### Motivation In the existing tests for `ConcurrentLongHashSet` and `ConcurrentLongLongHashMap`, the method `Math.abs(random.nextLong())` is used to generate keys. However, `Math.abs` can return a negative number if `Long.MIN_VALUE` is generated, which is problematic for tests that assume non-negative keys. Additionally, the assertions in the tests are using the older JUnit 4 style, which is less readable and not as flexible as JUnit 5. ### Changes 1. **Key Generation Fix**: Replaced `Math.abs(random.nextLong())` with `ThreadLocalRandom.current().nextLong(Long.MAX_VALUE)` to ensure that all generated keys are non-negative. 2. **Assertion Updates**: Updated all assertions in the `ConcurrentLongHashSetTest` and `ConcurrentLongLongHashMapTest` to use JUnit 5 style. This includes using `assertEquals`, `assertTrue`, `assertFalse`, and `assertNull` for better readability and consistency. Signed-off-by: ZhangJian He <[email protected]>
- Loading branch information
ZhangJian He
authored
May 7, 2024
1 parent
1ae4be0
commit c4fa8c2
Showing
2 changed files
with
63 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters