fix time parsing tests

This commit is contained in:
Bixilon 2023-01-28 18:01:31 +01:00
parent 4d58b71673
commit 71a9c1191e
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -1,6 +1,6 @@
/* /*
* Minosoft * Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger * Copyright (C) 2020-2023 Moritz Zwerger
* *
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* *
@ -26,36 +26,36 @@ internal class TimeParserTest {
@Test @Test
fun testNoUnit() { fun testNoUnit() {
val reader = CommandReader("1235") val reader = CommandReader("1235")
assertEquals(TimeParser.parse(reader), 1235) assertEquals(TimeParser().parse(reader), 1235)
} }
@Test @Test
fun testTickUnit() { fun testTickUnit() {
val reader = CommandReader("7382t") val reader = CommandReader("7382t")
assertEquals(TimeParser.parse(reader), 7382) assertEquals(TimeParser().parse(reader), 7382)
} }
@Test @Test
fun testSecondsUnit() { fun testSecondsUnit() {
val reader = CommandReader("64s") val reader = CommandReader("64s")
assertEquals(TimeParser.parse(reader), 64 * ProtocolDefinition.TICKS_PER_SECOND) assertEquals(TimeParser().parse(reader), 64 * ProtocolDefinition.TICKS_PER_SECOND)
} }
@Test @Test
fun testDaysUnit() { fun testDaysUnit() {
val reader = CommandReader("89d") val reader = CommandReader("89d")
assertEquals(TimeParser.parse(reader), 89 * ProtocolDefinition.TICKS_PER_DAY) assertEquals(TimeParser().parse(reader), 89 * ProtocolDefinition.TICKS_PER_DAY)
} }
@Test @Test
fun testEmpty() { fun testEmpty() {
val reader = CommandReader("") val reader = CommandReader("")
assertThrows<FloatParseError> { TimeParser.parse(reader) } assertThrows<FloatParseError> { TimeParser().parse(reader) }
} }
@Test @Test
fun testInvalidUnit() { fun testInvalidUnit() {
val reader = CommandReader("48i") val reader = CommandReader("48i")
assertThrows<InvalidTimeUnitError> { TimeParser.parse(reader) } assertThrows<InvalidTimeUnitError> { TimeParser().parse(reader) }
} }
} }