Skip to content

Commit

Permalink
Added parsing to test
Browse files Browse the repository at this point in the history
  • Loading branch information
anchouls committed Jul 31, 2023
1 parent 0953342 commit 417e481
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[*]
indent_size = 4
indent_style = space
indent_style = space
max_line_length = 120
insert_final_newline = true
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ files:
visible: true
placeholders:
- offset: 0
length: 40
length: 91
placeholder_text: ""
- name: test/EditorconfigTest.kt
visible: false
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.ini4j.Ini
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
Expand Down Expand Up @@ -26,12 +27,18 @@ class EditorconfigTest {

@Test
fun editorconfigFileContentTest() {
val sourceText = editorconfigFile.readText()
val expectedText = """
[*]
indent_size = 4
indent_style = space
""".trimIndent()
Assertions.assertEquals(expectedText, sourceText)
val ini = Ini(editorconfigFile)
Assertions.assertEquals("4", ini.get("*")?.get("indent_size")) {
"Please, define the settings so that the indentation size is equal to 4"
}
Assertions.assertEquals("space", ini.get("*")?.get("indent_style")) {
"Please, define the settings so that the indentation style is equal to space"
}
Assertions.assertEquals("120", ini.get("*")?.get("max_line_length")) {
"Please, define the settings so that the maximum line length is equal to 120"
}
Assertions.assertEquals("true", ini.get("*")?.get("insert_final_newline")) {
"Please, define the settings so that a newline character is added at the end of the last line in the file"
}
}
}
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ allprojects {
runtimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion")
implementation("org.junit.jupiter:junit-jupiter-params:$junitJupiterVersion")
runtimeOnly("org.junit.platform:junit-platform-console:1.9.0")

implementation("org.ini4j:ini4j:0.5.4")
}

tasks {
Expand Down

0 comments on commit 417e481

Please sign in to comment.