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
This commit is contained in:
parent
208e0a1a6f
commit
f4c7057daf
2 changed files with 33 additions and 0 deletions
|
@ -39,3 +39,8 @@ android {
|
||||||
jvmTarget = "1.8"
|
jvmTarget = "1.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
||||||
|
androidTestImplementation("androidx.test:runner:1.5.2")
|
||||||
|
}
|
|
@ -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<Array<String>> = arrayOf(
|
||||||
|
arrayOf("# Test", "<h1>Test</h1>\n"),
|
||||||
|
arrayOf("- [ ] Check this", "<ul>\n<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" disabled>Check this</li>\n</ul>\n"),
|
||||||
|
arrayOf("- [x] Checked!", "<ul>\n<li class=\"task-list-item\"><input type=\"checkbox\" class=\"task-list-item-checkbox\" disabled checked>Checked!</li>\n</ul>\n"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue