From f4c7057daf5cdc2d3413d0afcf60bdb00a8935d5 Mon Sep 17 00:00:00 2001 From: William Brawner Date: Sun, 5 May 2024 19:41:26 -0600 Subject: [PATCH] Add a couple of tests for markdown parsing I was trying to see if I had any memory issues but at least for the few tests I added, nothing seemed to stand out --- md4k/build.gradle.kts | 5 ++++ .../com/wbrawner/md4k/MarkdownParserTest.kt | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 md4k/src/androidTest/kotlin/com/wbrawner/md4k/MarkdownParserTest.kt diff --git a/md4k/build.gradle.kts b/md4k/build.gradle.kts index f364ed6..0db5dee 100644 --- a/md4k/build.gradle.kts +++ b/md4k/build.gradle.kts @@ -39,3 +39,8 @@ android { jvmTarget = "1.8" } } + +dependencies { + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test:runner:1.5.2") +} \ No newline at end of file diff --git a/md4k/src/androidTest/kotlin/com/wbrawner/md4k/MarkdownParserTest.kt b/md4k/src/androidTest/kotlin/com/wbrawner/md4k/MarkdownParserTest.kt new file mode 100644 index 0000000..4d3d7e8 --- /dev/null +++ b/md4k/src/androidTest/kotlin/com/wbrawner/md4k/MarkdownParserTest.kt @@ -0,0 +1,28 @@ +package com.wbrawner.md4k + +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.Parameterized +import org.junit.runners.Parameterized.Parameters + +@RunWith(Parameterized::class) +class MarkdownParserTest(private val markdown: String, private val html: String) { + + @Test + fun testMarkdownToHtmlConversion() { + val parsedHtml = markdown.toHtml() + assert(parsedHtml == html) { + """expected "$html", got "$parsedHtml"""" + } + } + + companion object { + @JvmStatic + @Parameters(name = "Markdown: {0}") + fun data(): Array> = arrayOf( + arrayOf("# Test", "

Test

\n"), + arrayOf("- [ ] Check this", "\n"), + arrayOf("- [x] Checked!", "\n"), + ) + } +} \ No newline at end of file