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:
Ilya Gorbunov
2017-12-22 21:19:51 +03:00
parent d9edc5f221
commit 10639eaf6a
2 changed files with 14 additions and 0 deletions
+11
View File
@@ -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"