Skip to content

Commit

Permalink
test(spdx-utils): Move testing toString() to the bottom
Browse files Browse the repository at this point in the history
This keeps test blocks named after functions grouped at the bottom.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Feb 14, 2024
1 parent 0d6b0bf commit de7247d
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions utils/spdx/src/test/kotlin/SpdxExpressionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,6 @@ import org.ossreviewtoolkit.utils.spdx.SpdxLicenseException.*

@Suppress("LargeClass")
class SpdxExpressionTest : WordSpec({
"toString()" should {
"return the textual SPDX expression" {
val expression = "a+ AND (b WITH exception1 OR c+) AND d WITH exception2"

expression.toSpdx() should beString(expression)
}

"not include unnecessary parenthesis" {
val expression = "(a AND (b AND c) AND (d OR (e WITH exception)))"

expression.toSpdx() should beString("a AND b AND c AND (d OR e WITH exception)")
}

"always add parentheses around groups with different operators" {
val expression1 = "a AND b AND c OR d AND e AND f"
val expression2 = "(a OR b OR c) AND (d OR e OR f)"
val expression3 = "(a OR b AND c) AND (d AND e OR f)"

expression1.toSpdx() should beString("(a AND b AND c) OR (d AND e AND f)")
expression2.toSpdx() should beString("(a OR b OR c) AND (d OR e OR f)")
expression3.toSpdx() should beString("(a OR (b AND c)) AND ((d AND e) OR f)")
}
}

"A dummy SpdxExpression" should {
val dummyExpression = "a+ AND (b WITH exception1 OR c+) AND d WITH exception2"

Expand Down Expand Up @@ -870,6 +846,30 @@ class SpdxExpressionTest : WordSpec({
"a AND (b OR c)".toSpdx().hashCode() shouldBe "(a AND b) OR (a AND c)".toSpdx().hashCode()
}
}

"toString()" should {
"return the textual SPDX expression" {
val expression = "a+ AND (b WITH exception1 OR c+) AND d WITH exception2"

expression.toSpdx() should beString(expression)
}

"not include unnecessary parenthesis" {
val expression = "(a AND (b AND c) AND (d OR (e WITH exception)))"

expression.toSpdx() should beString("a AND b AND c AND (d OR e WITH exception)")
}

"always add parentheses around groups with different operators" {
val expression1 = "a AND b AND c OR d AND e AND f"
val expression2 = "(a OR b OR c) AND (d OR e OR f)"
val expression3 = "(a OR b AND c) AND (d AND e OR f)"

expression1.toSpdx() should beString("(a AND b AND c) OR (d AND e AND f)")
expression2.toSpdx() should beString("(a OR b OR c) AND (d OR e OR f)")
expression3.toSpdx() should beString("(a OR (b AND c)) AND ((d AND e) OR f)")
}
}
})

private fun beString(expected: String): Matcher<SpdxExpression> =
Expand Down

0 comments on commit de7247d

Please sign in to comment.