projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
✅ Fix tests failing with non-English locales
[Sone.git]
/
src
/
test
/
kotlin
/
net
/
pterodactylus
/
sone
/
template
/
DurationFormatFilterTest.kt
diff --git
a/src/test/kotlin/net/pterodactylus/sone/template/DurationFormatFilterTest.kt
b/src/test/kotlin/net/pterodactylus/sone/template/DurationFormatFilterTest.kt
index
9e378a8
..
e14b46f
100644
(file)
--- 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
*
* 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
@@
-17,14
+17,20
@@
package net.pterodactylus.sone.template
package net.pterodactylus.sone.template
+import net.pterodactylus.sone.test.OverrideLocale
import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
+import org.junit.Rule
+import java.util.Locale.ENGLISH
import kotlin.test.*
class DurationFormatFilterTest {
private val filter = DurationFormatFilter()
import kotlin.test.*
class DurationFormatFilterTest {
private val filter = DurationFormatFilter()
+ @get:Rule
+ val overrideLocale = OverrideLocale(ENGLISH)
+
@Test
fun `random object is returned as it is`() {
val randomObject = Any()
@Test
fun `random object is returned as it is`() {
val randomObject = Any()
@@
-81,6
+87,16
@@
class DurationFormatFilterTest {
verifyDuration(123456789, "123.5ms", "ns")
}
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<Any>(expectedRendering))
}
private fun verifyDuration(value: Any, expectedRendering: String, scale: String? = null) {
assertThat(filter.format(null, value, scale?.let { mapOf("scale" to scale) } ?: emptyMap()), equalTo<Any>(expectedRendering))
}