BAEL-2648

This commit is contained in:
Rodrigo Graciano 2019-02-19 23:01:34 -05:00
parent bad8753fd1
commit b98294aaed
2 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,21 @@
package com.baeldung.range
enum class Color(val rgb: Int) {
BLUE(0x0000FF),
GREEN(0x008000),
RED(0xFF0000),
MAGENTA(0xFF00FF),
YELLOW(0xFFFF00);
}
fun main(args: Array<String>) {
println(Color.values().toList());
val red = Color.RED
val yellow = Color.YELLOW
val range = red..yellow
println(range.contains(Color.MAGENTA))
println(range.contains(Color.BLUE))
println(range.contains(Color.GREEN))
}

View File

@ -0,0 +1,20 @@
package com.baeldung.range
import org.junit.Test
import kotlin.test.assertFalse
import kotlin.test.assertTrue
class ColorTest {
@Test
fun testEnumRange() {
println(Color.values().toList());
val red = Color.RED
val yellow = Color.YELLOW
val range = red..yellow
assertTrue { range.contains(Color.MAGENTA) }
assertFalse { range.contains(Color.BLUE) }
}
}