This is an automated email from the ASF dual-hosted git repository.
vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git
The following commit(s) were added to refs/heads/master by this push:
new f2f7dc65c5 test: reduce the number of iterations in SearchByClassTest
f2f7dc65c5 is described below
commit f2f7dc65c5a3be7c848b7f7dc74d709fc2c57639
Author: Vladimir Sitnikov <[email protected]>
AuthorDate: Fri Jun 2 22:40:47 2023 +0300
test: reduce the number of iterations in SearchByClassTest
It is enough to find a first collision, so we can make the test faster
---
.../org/apache/jorphan/collections/SearchByClassTest.kt | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git
a/src/core/src/test/kotlin/org/apache/jorphan/collections/SearchByClassTest.kt
b/src/core/src/test/kotlin/org/apache/jorphan/collections/SearchByClassTest.kt
index 655808fd0e..1c0e3f5440 100644
---
a/src/core/src/test/kotlin/org/apache/jorphan/collections/SearchByClassTest.kt
+++
b/src/core/src/test/kotlin/org/apache/jorphan/collections/SearchByClassTest.kt
@@ -26,16 +26,22 @@ class SearchByClassTest {
@Test
fun `search finds all matching elements`() {
val tree = ListedHashTree()
- val count = 100000
- for (i in 0 until count) {
- tree.add(ThreadGroup())
+ val hashes = mutableSetOf<Int>()
+ for (i in 0 until 100000) {
+ val tg = ThreadGroup()
+ tree.add(tg)
+ if (!hashes.add(tg.hashCode())) {
+ // We already have a duplicate hashcode, so there's no need to
continue
+ break
+ }
}
val searcher = SearchByClass(
AbstractThreadGroup::class.java
)
tree.traverse(searcher)
- Assertions.assertEquals(count, searcher.searchResults.size) {
- "Test plan included $count ThreadGroup elements, so SearchByClass
should find all of them"
+ val expectedCount = hashes.size + 1
+ Assertions.assertEquals(expectedCount, searcher.searchResults.size) {
+ "Test plan included $expectedCount ThreadGroup elements, so
SearchByClass should find all of them"
}
}
}