From 8e0e16d1f40aaffc2a5bd7659d364cf5578176fb Mon Sep 17 00:00:00 2001 From: Kalle Struik Date: Sun, 5 Jun 2022 12:45:30 +0200 Subject: [PATCH] feat: Add a pipeline and some basic tests --- .drone.yml | 27 +++++++++++++++++++++++ src/test/kotlin/MainKtTest.kt | 40 +++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 .drone.yml create mode 100644 src/test/kotlin/MainKtTest.kt 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