mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log] fix extra space in time string, add tests
This commit is contained in:
@@ -91,9 +91,12 @@ public class StopWatch {
|
||||
result += quotient + (msec == 0 ? "" : "." + String.format(M_SEC_FORMAT, msec)) + UNIT_NAMES[i];
|
||||
}
|
||||
else {
|
||||
result += quotient + UNIT_NAMES[i] + " ";
|
||||
if (remainder == 0 && msec != 0) {
|
||||
result += "0." + String.format(M_SEC_FORMAT, msec) + UNIT_NAMES[0];
|
||||
result += quotient + UNIT_NAMES[i];
|
||||
if (remainder != 0 || msec != 0) {
|
||||
result += " ";
|
||||
if (remainder == 0) {
|
||||
result += "0." + String.format(M_SEC_FORMAT, msec) + UNIT_NAMES[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.vcs.log.util
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class StopWatchTestCase {
|
||||
@Test
|
||||
fun testEvenMinutes() {
|
||||
assertEquals("1m", StopWatch.formatTime(60000))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testEvenSeconds() {
|
||||
assertEquals("1m 5s", StopWatch.formatTime(65000))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testUnEvenSeconds() {
|
||||
assertEquals("1m 5.100s", StopWatch.formatTime(65100))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user