Add pattern and options properties to common Regex
And add a test that accesses them and checks they work as expected.
This commit is contained in:
@@ -7,6 +7,17 @@ import kotlin.test.*
|
||||
|
||||
class RegexTest {
|
||||
|
||||
@Test fun properties() {
|
||||
val pattern = "\\s+$"
|
||||
val regex1 = Regex(pattern, RegexOption.IGNORE_CASE)
|
||||
assertEquals(pattern, regex1.pattern)
|
||||
assertEquals(setOf(RegexOption.IGNORE_CASE), regex1.options)
|
||||
|
||||
val options2 = setOf(RegexOption.MULTILINE, RegexOption.IGNORE_CASE)
|
||||
val regex2 = Regex(pattern, options2)
|
||||
assertEquals(options2, regex2.options)
|
||||
}
|
||||
|
||||
@Test fun matchResult() {
|
||||
val p = "\\d+".toRegex()
|
||||
val input = "123 456 789"
|
||||
|
||||
Reference in New Issue
Block a user