BAEL-2648
This commit is contained in:
parent
bad8753fd1
commit
b98294aaed
|
@ -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))
|
||||
}
|
|
@ -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) }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue