=tes #15357 fix for PrettyDurationSpec
This commit is contained in:
parent
3a12375c5f
commit
a165f6da92
1 changed files with 14 additions and 12 deletions
|
|
@ -4,6 +4,7 @@
|
|||
package akka.testkit.metrics.reporter
|
||||
|
||||
import org.scalatest.{ Matchers, FlatSpec }
|
||||
import java.util.Locale
|
||||
|
||||
class PrettyDurationSpec extends FlatSpec with Matchers {
|
||||
|
||||
|
|
@ -12,21 +13,22 @@ class PrettyDurationSpec extends FlatSpec with Matchers {
|
|||
import concurrent.duration._
|
||||
import PrettyDuration._
|
||||
|
||||
val cases =
|
||||
9.nanos -> "9.000 ns" ::
|
||||
95.nanos -> "95.00 ns" ::
|
||||
999.nanos -> "999.0 ns" ::
|
||||
1000.nanos -> "1.000 μs" ::
|
||||
9500.nanos -> "9.500 μs" ::
|
||||
9500.micros -> "9.500 ms" ::
|
||||
9500.millis -> "9.500 s" ::
|
||||
95.seconds -> "1.583 min" ::
|
||||
95.minutes -> "1.583 h" ::
|
||||
95.hours -> "3.958 d" ::
|
||||
val cases: Seq[(Duration, (Float, Int, String))] =
|
||||
9.nanos -> ((9.000f, 3, "ns")) ::
|
||||
95.nanos -> ((95.00f, 2, "ns")) ::
|
||||
999.nanos -> ((999.0f, 1, "ns")) ::
|
||||
1000.nanos -> ((1.000f, 3, "μs")) ::
|
||||
9500.nanos -> ((9.500f, 3, "μs")) ::
|
||||
9500.micros -> ((9.500f, 3, "ms")) ::
|
||||
9500.millis -> ((9.500f, 3, "s")) ::
|
||||
95.seconds -> ((1.583f, 3, "min")) ::
|
||||
95.minutes -> ((1.583f, 3, "h")) ::
|
||||
95.hours -> ((3.958f, 3, "d")) ::
|
||||
Nil
|
||||
|
||||
cases foreach {
|
||||
case (d, prettyString) ⇒
|
||||
case (d, (expectedValue, precision, unit)) ⇒
|
||||
val prettyString = s"%.${precision}f $unit" formatLocal (Locale.getDefault, expectedValue)
|
||||
it should s"print $d seconds as $prettyString" in {
|
||||
d.pretty should equal(prettyString)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue