mirror of
https://github.com/TeamAmaze/AmazeFileManager.git
synced 2026-10-18 13:51:20 +08:00
Test case for Utils.formatTimer
This commit is contained in:
@@ -262,7 +262,6 @@ public class Utils {
|
||||
* Formats input to plain mm:ss format
|
||||
*/
|
||||
public static String formatTimer(long timer) {
|
||||
|
||||
final long min = timer / 60;
|
||||
final long sec = timer % 60;
|
||||
return String.format(Locale.US, "%02d:%02d", min, sec);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.amaze.filemanager.utils;
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.amaze.filemanager.utils.Utils.sanitizeInput;
|
||||
import static com.amaze.filemanager.utils.Utils.formatTimer;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class UtilsTest {
|
||||
@@ -17,4 +18,13 @@ public class UtilsTest {
|
||||
assertEquals("an apple",sanitizeInput("an ...apple")); //test the removing of dots which are between two words.
|
||||
assertEquals("an apple.",sanitizeInput(";an |apple....")); //test the removing of pipe sign and dots which are between two words. And test the fourth dot is not removed.
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatTimer() {
|
||||
assertEquals("10:00", formatTimer(600));
|
||||
assertEquals("00:00", formatTimer(0));
|
||||
assertEquals("00:45", formatTimer(45));
|
||||
assertEquals("02:45", formatTimer(165));
|
||||
assertEquals("30:33", formatTimer(1833));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user