Skip to content

Commit

Permalink
Add test with multiline if condition
Browse files Browse the repository at this point in the history
  • Loading branch information
csgulley committed Apr 26, 2020
1 parent 0a9e28a commit bf311f0
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,41 @@ class MultiLineIfElseRuleTest {
)
}

@Test
fun testMultilineCondition() {
val ifElseWithoutCurlyBrace =
"""
fun main() {
if (i2 > 0 &&
i3 < 0
)
return 2
else
return 3
}
""".trimIndent()

assertThat(lint(ifElseWithoutCurlyBrace)).isEqualTo(
listOf(
LintError(5, 9, "multiline-if-else", "Missing { ... }"),
LintError(7, 9, "multiline-if-else", "Missing { ... }")
)
)
assertThat(format(ifElseWithoutCurlyBrace)).isEqualTo(
"""
fun main() {
if (i2 > 0 &&
i3 < 0
) {
return 2
} else {
return 3
}
}
""".trimIndent()
)
}

private fun assertOK(kotlinScript: String) {
Assertions.assertThat(format(kotlinScript)).isEqualTo(kotlinScript)
Assertions.assertThat(lint(kotlinScript)).isEqualTo(emptyList<LintError>())
Expand Down

0 comments on commit bf311f0

Please sign in to comment.