mirror of
https://github.com/Anvilcraft/modpacktools
synced 2024-06-02 18:49:31 +02:00
rename tests
This commit is contained in:
parent
e67995d6a0
commit
e838e48f42
|
@ -6,13 +6,13 @@ import java.io.ByteArrayOutputStream
|
||||||
import java.io.PrintStream
|
import java.io.PrintStream
|
||||||
|
|
||||||
class CLIUtilTest {
|
class CLIUtilTest {
|
||||||
fun prntStr(f: PrintStream.() -> Unit): String =
|
private fun prntStr(f: PrintStream.() -> Unit): String =
|
||||||
ByteArrayOutputStream().apply {
|
ByteArrayOutputStream().apply {
|
||||||
PrintStream(this, true, "UTF-8").use(f)
|
PrintStream(this, true, "UTF-8").use(f)
|
||||||
}.use {it.toString("UTF-8")}
|
}.use {it.toString("UTF-8")}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testFPrintln() {
|
fun fPrintLn() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Test String Formatted\n",
|
"Test String Formatted\n",
|
||||||
prntStr {this.fPrintln("Test String", {"$it Formatted"})}
|
prntStr {this.fPrintln("Test String", {"$it Formatted"})}
|
||||||
|
@ -20,7 +20,7 @@ class CLIUtilTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testFPrintlnNull() {
|
fun `fPrintLn with null`() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"null\n",
|
"null\n",
|
||||||
prntStr {this.fPrintln(null)}
|
prntStr {this.fPrintln(null)}
|
||||||
|
|
|
@ -8,13 +8,13 @@ import java.net.URL
|
||||||
|
|
||||||
class UtilTest {
|
class UtilTest {
|
||||||
@Test
|
@Test
|
||||||
fun testSanitize() = assertEquals(URL("https://example.com/test%20test"), URL("https://example.com/test test").sanitize())
|
fun sanitize() = assertEquals(URL("https://example.com/test%20test"), URL("https://example.com/test test").sanitize())
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testMergeTo() = assertEquals(File("testing/dir"), File("testing") mergeTo File("dir"))
|
fun mergeTo() = assertEquals(File("testing/dir"), File("testing") mergeTo File("dir"))
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testReadAsJson() {
|
fun readAsJson() {
|
||||||
val tmpDir = TemporaryFolder().apply {create()}
|
val tmpDir = TemporaryFolder().apply {create()}
|
||||||
val testFile = tmpDir.newFile()
|
val testFile = tmpDir.newFile()
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.junit.Assert.assertNull
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class ConfigTomlTest {
|
class ConfigTomlTest {
|
||||||
val toml = ConfigToml().read(
|
private val toml = ConfigToml().read(
|
||||||
"""
|
"""
|
||||||
[SomeCategory]
|
[SomeCategory]
|
||||||
someValue = 123
|
someValue = 123
|
||||||
|
@ -13,7 +13,7 @@ class ConfigTomlTest {
|
||||||
) as ConfigToml
|
) as ConfigToml
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testGetPath() {
|
fun getPath() {
|
||||||
//String getPath
|
//String getPath
|
||||||
assertEquals(
|
assertEquals(
|
||||||
123L,
|
123L,
|
||||||
|
@ -22,19 +22,22 @@ class ConfigTomlTest {
|
||||||
|
|
||||||
//should be null if invalid category
|
//should be null if invalid category
|
||||||
assertNull(toml.getPath("NonExistentCategory/val"))
|
assertNull(toml.getPath("NonExistentCategory/val"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `getPath with invalid path`() {
|
||||||
//should be null if invalid value
|
//should be null if invalid value
|
||||||
assertNull(toml.getPath("SomeCategory/val"))
|
assertNull(toml.getPath("SomeCategory/val"))
|
||||||
}
|
}
|
||||||
|
|
||||||
//should throw exception
|
//should throw exception
|
||||||
@Test(expected = MissingConfigValueException::class)
|
@Test(expected = MissingConfigValueException::class)
|
||||||
fun testPathOrExceptionMissing() {
|
fun `pathOrException with invalid path`() {
|
||||||
toml.pathOrException<Long>("Asd/asd")
|
toml.pathOrException<Long>("Asd/asd")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testPathOrException() {
|
fun pathOrException() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
123L,
|
123L,
|
||||||
toml.pathOrException("SomeCategory/someValue")
|
toml.pathOrException("SomeCategory/someValue")
|
||||||
|
|
Loading…
Reference in a new issue