33 lines
661 B
Gleam
33 lines
661 B
Gleam
import gleam/list
|
|
import gleeunit
|
|
|
|
import musicplayer/time/time
|
|
|
|
pub fn main() -> Nil {
|
|
gleeunit.main()
|
|
}
|
|
|
|
type TestCase {
|
|
TestCase(seconds: Float, expected: String)
|
|
}
|
|
|
|
pub fn to_duration_string_test() {
|
|
let test_cases = [
|
|
TestCase(-1.0, "00:00"),
|
|
TestCase(0.0, "00:00"),
|
|
TestCase(9.0, "00:09"),
|
|
TestCase(10.0, "00:10"),
|
|
TestCase(11.0, "00:11"),
|
|
TestCase(60.0, "01:00"),
|
|
TestCase(61.0, "01:01"),
|
|
TestCase(120.0, "02:00"),
|
|
TestCase(600.0, "10:00"),
|
|
TestCase(6000.0, "100:00"),
|
|
TestCase(6001.0, "100:01"),
|
|
]
|
|
|
|
list.each(test_cases, fn(tc) {
|
|
assert tc.expected == time.to_duration_string(tc.seconds)
|
|
})
|
|
}
|