Added unit-test/example

This commit is contained in:
nathan 2020-10-06 01:50:15 +02:00
parent 2aa9f12b39
commit ac6b550dec
1 changed files with 21 additions and 2 deletions

View File

@ -1,3 +1,18 @@
/*
* Copyright 2020 dorkbox, llc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dorkbox.objectPool
import kotlinx.coroutines.runBlocking
@ -57,8 +72,12 @@ class BlockingTest {
val take1 = pool.take()
val take2 = pool.take()
val take3 = pool.take()
val take4 = pool.take() // this suspends
Assert.fail("shouldn't get here")
// val take4 = pool.take() // this suspends
// Assert.fail("shouldn't get here")
pool.put(take3)
Assert.assertTrue(pool.take() === take3)
}
}
}