You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1013 B
44 lines
1013 B
/**
|
|
* Copyright (C) 2022, Tim Holloway
|
|
*
|
|
* Date written: Jan 8, 2022
|
|
* Author: Tim Holloway <timh@mousetech.com>
|
|
*/
|
|
package com.mousetech.gourmetj.utils;
|
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
import org.junit.jupiter.api.BeforeAll;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
/**
|
|
* @author timh
|
|
* @since Jan 8, 2022
|
|
*/
|
|
class TimeFormatterTest {
|
|
|
|
/**
|
|
* @throws java.lang.Exception
|
|
*/
|
|
@BeforeAll
|
|
static void setUpBeforeClass() throws Exception {
|
|
}
|
|
|
|
@Test
|
|
void test() {
|
|
assertEquals(5000, TimeFormatter.parseTime("5s"));
|
|
assertEquals(5000*60, TimeFormatter.parseTime("5m"));
|
|
|
|
assertEquals(3600_000 + 25*60_000, TimeFormatter.parseTime("1 hour, 25 min"));
|
|
|
|
assertEquals(5*3600000 + 6*60000, TimeFormatter.parseTime("5h 6m"));
|
|
assertEquals(277562000L, TimeFormatter.parseTime("3d 5h 6m 2s"));
|
|
|
|
assertEquals(18000000L, TimeFormatter.parseTime("1.5 hours"));
|
|
|
|
assertEquals(3*3600_000, TimeFormatter.parseTime("3 hours"));
|
|
|
|
assertNull(TimeFormatter.parseTime("1 week"));
|
|
}
|
|
|
|
}
|
|
|