Skip to content

Commit

Permalink
Try to fix test on Windows
Browse files Browse the repository at this point in the history
Closes #2658
  • Loading branch information
paul-dingemans committed May 28, 2024
1 parent ec0b87f commit 004c7a7
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.assertj.core.api.Assertions.assertThat
import org.jetbrains.kotlin.com.intellij.lang.ASTNode
import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LeafElement
import org.jetbrains.kotlin.com.intellij.psi.tree.IElementType
import org.jetbrains.kotlin.utils.addToStdlib.applyIf
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test

Expand Down Expand Up @@ -285,7 +286,12 @@ class KtLintTest {

@Test
fun testFormatUnicodeBom() {
val code = getResourceAsText("spec/format-unicode-bom.kt.spec")
val code =
getResourceAsText("spec/format-unicode-bom.kt.spec")
.applyIf(System.lineSeparator() != "\n") {
// On Windows change the input code to conform with the default lineSeparator "\r\n" as otherwise the assertion fails
replace("\n", System.lineSeparator())
}

val actual =
KtLintRuleEngine(
Expand All @@ -295,6 +301,8 @@ class KtLintTest {
),
).format(Code.fromSnippet(code))

//
assertThat(code.toByteArray()).isEqualTo(actual.toByteArray())
assertThat(actual).isEqualTo(code)
}

Expand Down

0 comments on commit 004c7a7

Please sign in to comment.