Skip to content

Commit b98294a

Browse files
BAEL-2648
1 parent bad8753 commit b98294a

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.baeldung.range
2+
3+
enum class Color(val rgb: Int) {
4+
BLUE(0x0000FF),
5+
GREEN(0x008000),
6+
RED(0xFF0000),
7+
MAGENTA(0xFF00FF),
8+
YELLOW(0xFFFF00);
9+
}
10+
11+
fun main(args: Array<String>) {
12+
13+
println(Color.values().toList());
14+
val red = Color.RED
15+
val yellow = Color.YELLOW
16+
val range = red..yellow
17+
18+
println(range.contains(Color.MAGENTA))
19+
println(range.contains(Color.BLUE))
20+
println(range.contains(Color.GREEN))
21+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.baeldung.range
2+
3+
import org.junit.Test
4+
import kotlin.test.assertFalse
5+
import kotlin.test.assertTrue
6+
7+
class ColorTest {
8+
9+
@Test
10+
fun testEnumRange() {
11+
12+
println(Color.values().toList());
13+
val red = Color.RED
14+
val yellow = Color.YELLOW
15+
val range = red..yellow
16+
17+
assertTrue { range.contains(Color.MAGENTA) }
18+
assertFalse { range.contains(Color.BLUE) }
19+
}
20+
}

0 commit comments

Comments
 (0)