Skip to content

Commit bb287f0

Browse files
committed
test: Verify normalized string format of duration
Add test cases to verify that a duration returns a normalized value.
1 parent 61a5064 commit bb287f0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/test/scala/org/camunda/feel/api/StringRepresentationTypeTest.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ class StringRepresentationTypeTest extends AnyFlatSpec with Matchers {
121121
duration.toString should be("P2M")
122122
}
123123

124+
it should "return normalized format " in {
125+
ValYearMonthDuration(Period.parse("P2Y")).toString should be("P2Y")
126+
ValYearMonthDuration(Period.parse("P24M")).toString should be("P2Y")
127+
128+
ValYearMonthDuration(Period.parse("P25M")).toString should be("P2Y1M")
129+
ValYearMonthDuration(Period.parse("P35M")).toString should be("P2Y11M")
130+
}
131+
124132
"A days-time-duration" should "return 'P1DT2H3M4S' " in {
125133
val duration = ValDayTimeDuration(Duration.parse("P1DT2H3M4S"))
126134

@@ -151,6 +159,17 @@ class StringRepresentationTypeTest extends AnyFlatSpec with Matchers {
151159
duration.toString should be("PT4S")
152160
}
153161

162+
it should "return normalized format " in {
163+
ValDayTimeDuration(Duration.parse("P5D")).toString should be("P5D")
164+
ValDayTimeDuration(Duration.parse("PT120H")).toString should be("P5D")
165+
ValDayTimeDuration(Duration.parse("PT7200M")).toString should be("P5D")
166+
ValDayTimeDuration(Duration.parse("PT432000S")).toString should be("P5D")
167+
168+
ValDayTimeDuration(Duration.parse("PT121H")).toString should be("P5DT1H")
169+
ValDayTimeDuration(Duration.parse("PT7201M")).toString should be("P5DT1M")
170+
ValDayTimeDuration(Duration.parse("PT7261M")).toString should be("P5DT1H1M")
171+
}
172+
154173
"A list" should "return '[1, 2]' " in {
155174
ValList(List(ValNumber(1), ValNumber(2))).toString should be("[1, 2]")
156175
}

0 commit comments

Comments
 (0)