X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FDurationFormatFilterTest.kt;h=0af4a8ef1e0b2af0f62a77c4451359463534f0bc;hb=faf66247a34f64946990a985d2ea3003465969cb;hp=9e378a805274ec910ce8d9304a2080e48cebe0bb;hpb=6579401cd867c5ade1ebf098d64d85dc2016defe;p=Sone.git diff --git a/src/test/kotlin/net/pterodactylus/sone/template/DurationFormatFilterTest.kt b/src/test/kotlin/net/pterodactylus/sone/template/DurationFormatFilterTest.kt index 9e378a8..0af4a8e 100644 --- a/src/test/kotlin/net/pterodactylus/sone/template/DurationFormatFilterTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/template/DurationFormatFilterTest.kt @@ -1,5 +1,5 @@ /** - * Sone - DurationFormatFilterTest.kt - Copyright © 2019 David ‘Bombe’ Roden + * Sone - DurationFormatFilterTest.kt - Copyright © 2019–2020 David ‘Bombe’ Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -81,6 +81,16 @@ class DurationFormatFilterTest { verifyDuration(123456789, "123.5ms", "ns") } + @Test + fun `123456 with scale ns is rendered as “123_5μs”`() { + verifyDuration(123456, "123.5μs", "ns") + } + + @Test + fun `123 with scale ns is rendered as “123_0ns”`() { + verifyDuration(123, "123.0ns", "ns") + } + private fun verifyDuration(value: Any, expectedRendering: String, scale: String? = null) { assertThat(filter.format(null, value, scale?.let { mapOf("scale" to scale) } ?: emptyMap()), equalTo(expectedRendering)) }