Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dimension.toString() displays "dimensionless" when dimension is … #250

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class Dimension(
private val elements: Map<String, Double>

override fun toString(): String {
if (elements.isEmpty()) {
return "dimensionless"
}
return elements.entries.joinToString(".") {
simpleDimToString(it)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package ch.kleis.lcaplugin.core.lang.dimension

import kotlin.test.assertEquals
import org.junit.Test


class DimensionTest {

@Test
fun test_toString_whenNone() {
// given
val dimension = Dimension.None

// when
val actual = "$dimension"

// then
assertEquals("dimensionless", actual)
}

@Test
fun test_toString_whenSimpleDim() {
// given
val dimension = Dimension.of("something")

// when
val actual ="$dimension"

// then
assertEquals("something", actual)
}

@Test
fun test_toString_whenSmallPower() {
// given
val dimension = Dimension.of("something", 2)

// when
val actual ="$dimension"

// then
assertEquals("something²", actual)
}
}
Loading