Rename methods in Regex. Add matchEntire method to match entire string against regex.

This commit is contained in:
Ilya Gorbunov
2015-10-14 07:44:19 +03:00
parent d860f335a3
commit d1d865aa0f
7 changed files with 80 additions and 26 deletions
@@ -32,7 +32,7 @@ internal fun getUsedMemoryKb(): Long {
private fun comparableVersionStr(version: String) =
"(\\d+)\\.(\\d+).*"
.toRegex()
.match(version)
.find(version)
?.groups
?.drop(1)?.take(2)
// checking if two subexpression groups are found and length of each is >0 and <4
@@ -64,7 +64,7 @@ class KotlinGradleIT: BaseGradleIT() {
for (i in 1..3) {
project.build(userVariantArg, "build", options = BaseGradleIT.BuildOptions(withDaemon = true)) {
assertSuccessful()
val matches = "\\[PERF\\] Used memory after build: (\\d+) kb \\(([+-]?\\d+) kb\\)".toRegex().match(output)
val matches = "\\[PERF\\] Used memory after build: (\\d+) kb \\(([+-]?\\d+) kb\\)".toRegex().find(output)
assert(matches != null && matches.groups.size() == 3, "Used memory after build is not reported by plugin")
val reportedGrowth = matches!!.groups.get(2)!!.value.removePrefix("+").toInt()
assert(reportedGrowth <= 700, "Used memory growth $reportedGrowth > 700")