Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct conversion between bytes and other units (#347)
- Loading branch information
Showing
2 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
hoplite-core/src/test/kotlin/com/sksamuel/hoplite/decoder/SizeInBytesDecoderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.sksamuel.hoplite.decoder | ||
|
||
import io.kotest.core.spec.style.FunSpec | ||
import io.kotest.matchers.shouldBe | ||
|
||
class SizeInBytesDecoderTest : FunSpec({ | ||
val units = listOf( | ||
InformationUnit.Kilobytes, | ||
InformationUnit.Megabytes, | ||
InformationUnit.Gigabytes, | ||
|
||
InformationUnit.Octets, | ||
InformationUnit.Kibibytes, | ||
InformationUnit.Mebibytes, | ||
InformationUnit.Gibibytes | ||
) | ||
|
||
test("conversion between bytes and other units") { | ||
val size = 8 | ||
for (unit in units) { | ||
SizeInBytes((size * unit.ratioToPrimary).toLong()).convert(unit) shouldBe size | ||
} | ||
} | ||
}) |