Reformat stdlib tests and samples

#KT-5558
This commit is contained in:
Ilya Gorbunov
2018-04-23 16:18:24 +03:00
parent add09e0f2e
commit ecf0d7ec0d
39 changed files with 389 additions and 284 deletions
+16 -11
View File
@@ -14,7 +14,8 @@ data class Item(val name: String, val rating: Int) : Comparable<Item> {
}
}
val STRING_CASE_INSENSITIVE_ORDER: Comparator<String> = compareBy { it: String -> it.toUpperCase() }.thenBy { it.toLowerCase() }.thenBy { it }
val STRING_CASE_INSENSITIVE_ORDER: Comparator<String> =
compareBy { it: String -> it.toUpperCase() }.thenBy { it.toLowerCase() }.thenBy { it }
class OrderingTest {
val v1 = Item("wine", 9)
@@ -72,13 +73,13 @@ class OrderingTest {
val byRating = compareBy<Item> { it.rating }
val v3 = Item(v1.name, v1.rating + 1)
val v4 = Item(v2.name + "_", v2.rating)
assertTrue( (byName then byRating).compare(v1, v2) > 0 )
assertTrue( (byName then byRating).compare(v1, v3) < 0 )
assertTrue( (byName thenDescending byRating).compare(v1, v3) > 0 )
assertTrue((byName then byRating).compare(v1, v2) > 0)
assertTrue((byName then byRating).compare(v1, v3) < 0)
assertTrue((byName thenDescending byRating).compare(v1, v3) > 0)
assertTrue( (byRating then byName).compare(v1, v2) < 0 )
assertTrue( (byRating then byName).compare(v4, v2) > 0 )
assertTrue( (byRating thenDescending byName).compare(v4, v2) < 0 )
assertTrue((byRating then byName).compare(v1, v2) < 0)
assertTrue((byRating then byName).compare(v4, v2) > 0)
assertTrue((byRating thenDescending byName).compare(v4, v2) < 0)
}
@Test
@@ -150,7 +151,8 @@ class OrderingTest {
assertEquals(v1, items[1])
}
@Test fun maxOf() {
@Test
fun maxOf() {
assertEquals(Int.MAX_VALUE, maxOf(Int.MAX_VALUE, Int.MIN_VALUE))
assertEquals(Int.MAX_VALUE, maxOf(Int.MAX_VALUE, Int.MIN_VALUE, 0))
@@ -161,14 +163,16 @@ class OrderingTest {
assertEquals(Double.POSITIVE_INFINITY, maxOf(Double.POSITIVE_INFINITY, Double.MAX_VALUE, Double.MIN_VALUE))
}
@Test fun maxOfWith() {
@Test
fun maxOfWith() {
assertEquals(v1, maxOf(v1, v2, compareBy { it.name }))
assertEquals(v1, maxOf(v3, v2, v1, compareBy { it.name }))
assertEquals(v2, maxOf(v1, v2, compareBy { it.rating }))
assertEquals(v3, maxOf(v1, v2, v3, compareBy { it.rating }))
}
@Test fun minOf() {
@Test
fun minOf() {
assertEquals(Int.MIN_VALUE, minOf(Int.MAX_VALUE, Int.MIN_VALUE))
assertEquals(Int.MIN_VALUE, minOf(Int.MAX_VALUE, Int.MIN_VALUE, 0))
@@ -179,7 +183,8 @@ class OrderingTest {
assertEquals(Double.MIN_VALUE, minOf(Double.POSITIVE_INFINITY, Double.MAX_VALUE, Double.MIN_VALUE))
}
@Test fun minOfWith() {
@Test
fun minOfWith() {
assertEquals(v2, minOf(v1, v2, compareBy { it.name }))
assertEquals(v3, minOf(v3, v2, v1, compareBy { it.name }))
assertEquals(v1, minOf(v1, v2, compareBy { it.rating }))