Skip to content

Commit

Permalink
Add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
dom-apuliasoft committed Jul 10, 2024
1 parent 5b64cbd commit dd8b530
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.smeup.rpgparser.smeup

import com.smeup.rpgparser.interpreter.TimeStampValue
import com.smeup.rpgparser.parsing.parsetreetoast.AstResolutionError
import org.junit.Test
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.temporal.ChronoUnit
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith

Expand Down Expand Up @@ -30,4 +33,33 @@ open class MULANGT04EssentialsCodopAndBifTest : MULANGTTest() {
)
assertEquals(expected, "smeup/T04_A80_P05".outputOf())
}

/**
* %DIFF with several DurationCodes
*/
@Test
fun executeMUDRNRAPU00228() {
val referenceDate = TimeStampValue.of("2024-07-10-10.25.27.921456")
val epochDate = TimeStampValue.of("1970-01-01-00.00.00.000000")
val referenceInstant = referenceDate.asTimeStamp().value.atZone(ZoneId.systemDefault()).toInstant()
val epochInstant = epochDate.asTimeStamp().value.atZone(ZoneId.systemDefault()).toInstant()

val mseconds = ChronoUnit.MICROS.between(epochInstant, referenceInstant).toString()
val seconds = ChronoUnit.SECONDS.between(epochInstant, referenceInstant).toString()
val minutes = ChronoUnit.MINUTES.between(epochInstant, referenceInstant).toString()
val hours = ChronoUnit.HOURS.between(epochInstant, referenceInstant).toString()
val days = ChronoUnit.DAYS.between(epochInstant, referenceInstant).toString()
val months = ChronoUnit.MONTHS.between(epochDate.localDate, referenceDate.localDate).toString()
val years = ChronoUnit.YEARS.between(epochDate.localDate, referenceDate.localDate).toString()
val expected = listOf(
mseconds, mseconds,
seconds, seconds,
minutes, minutes,
hours, hours,
days, days,
months, months,
years, years
)
assertEquals(expected, "smeup/MUDRNRAPU00228".outputOf())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
D ut S 30 0
D dt S Z INZ(Z'2024-07-10-10.25.27.921456')
D t S Z INZ(Z'1970-01-01-00.00.00.000000')

C EVAL ut=%diff(dt:t:*mseconds)
C ut DSPLY
C EVAL ut=%diff(dt:t:*ms)
C ut DSPLY
C EVAL ut=%diff(dt:t:*seconds)
C ut DSPLY
C EVAL ut=%diff(dt:t:*s)
C ut DSPLY
C EVAL ut=%diff(dt:t:*minutes)
C ut DSPLY
C EVAL ut=%diff(dt:t:*mn)
C ut DSPLY
C EVAL ut=%diff(dt:t:*hours)
C ut DSPLY
C EVAL ut=%diff(dt:t:*h)
C ut DSPLY
C EVAL ut=%diff(dt:t:*days)
C ut DSPLY
C EVAL ut=%diff(dt:t:*d)
C ut DSPLY
C EVAL ut=%diff(dt:t:*months)
C ut DSPLY
C EVAL ut=%diff(dt:t:*m)
C ut DSPLY
C EVAL ut=%diff(dt:t:*years)
C ut DSPLY
C EVAL ut=%diff(dt:t:*y)
C ut DSPLY

0 comments on commit dd8b530

Please sign in to comment.