Minor: refactor some tests to use nested classes.
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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 test.collections
|
||||
|
||||
import java.util.*
|
||||
@@ -594,7 +610,7 @@ class CollectionTest {
|
||||
assertFalse(hashSetOf<Int>().contains(12))
|
||||
assertTrue(listOf(15, 19, 20).contains(15))
|
||||
|
||||
assertTrue(IterableWrapper(hashSetOf(45, 14, 13)).contains(14))
|
||||
assertTrue(hashSetOf(45, 14, 13).toIterable().contains(14))
|
||||
}
|
||||
|
||||
@test fun min() {
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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 test.collections
|
||||
|
||||
import org.junit.Test
|
||||
@@ -5,15 +21,8 @@ import java.util.ArrayList
|
||||
import java.util.LinkedHashSet
|
||||
import kotlin.test.*
|
||||
|
||||
fun <T> iterableOf(vararg items: T): Iterable<T> = IterableWrapper(items.toList())
|
||||
|
||||
class IterableWrapper<T>(collection: Iterable<T>) : Iterable<T> {
|
||||
private val collection = collection
|
||||
|
||||
override fun iterator(): Iterator<T> {
|
||||
return collection.iterator()
|
||||
}
|
||||
}
|
||||
fun <T> iterableOf(vararg items: T): Iterable<T> = Iterable { items.iterator() }
|
||||
fun <T> Iterable<T>.toIterable(): Iterable<T> = Iterable { this.iterator() }
|
||||
|
||||
class IterableTest : OrderedIterableTests<Iterable<String>>(iterableOf("foo", "bar"), iterableOf<String>())
|
||||
class SetTest : IterableTests<Set<String>>(setOf("foo", "bar"), setOf<String>())
|
||||
|
||||
Reference in New Issue
Block a user