diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..3b71f62 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,27 @@ +--- +kind: pipeline +type: docker +name: default + +steps: +- name: "Build" + image: "eclipse-temurin:16-jdk" + commands: + - "./gradlew assemble" +- name: "Test" + image: "eclipse-temurin:16-jdk" + commands: + - "./gradlew test" +- name: "Create Release" + image: plugins/gitea-release + settings: + api_key: + from_secret: "gitea_api_key" + base_url: + from_secret: "gitea_base_url" + files: build/libs/CSharpCommentChecker-*.jar + when: + branch: + - master + + diff --git a/src/test/kotlin/MainKtTest.kt b/src/test/kotlin/MainKtTest.kt new file mode 100644 index 0000000..b117762 --- /dev/null +++ b/src/test/kotlin/MainKtTest.kt @@ -0,0 +1,40 @@ +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test + +internal class MainKtTest { + + @Test + fun `groupCommentLines groups two adjacent lines`() { + val lines = listOf(1, 2) + + assertEquals(listOf(listOf(1, 2)), groupCommentLines(lines)) + } + + @Test + fun `groupCommentLines doesn't group two non adjacent lines`() { + val lines = listOf(1, 3) + + assertEquals(listOf(listOf(1), listOf(3)), groupCommentLines(lines)) + } + + @Test + fun `groupCommentLines groups larger groups`() { + val lines = listOf(1, 2, 3, 4, 5) + + assertEquals(listOf(listOf(1, 2, 3, 4, 5)), groupCommentLines(lines)) + } + + @Test + fun `groupCommentLines groups multiple groups`() { + val lines = listOf(1, 2, 3, 5, 6, 7) + + assertEquals(listOf(listOf(1, 2, 3), listOf(5, 6, 7)), groupCommentLines(lines)) + } + + @Test + fun `groupCommentLines without any comments`() { + val lines = emptyList() + + assertEquals(emptyList>(), groupCommentLines(lines)) + } +} \ No newline at end of file