Skip to content

Commit 8fce19e

Browse files
committed
add test for realTimeZonedDateTime
1 parent ac7689c commit 8fce19e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/jvm-native/src/test/scala/cats/effect/SyncIOPlatformSuite.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package cats.effect
1818

19+
import java.time.ZoneOffset
20+
1921
trait SyncIOPlatformSuite { self: BaseSuite =>
2022
def platformTests() = {
2123

@@ -30,6 +32,22 @@ trait SyncIOPlatformSuite { self: BaseSuite =>
3032
assertCompleteAsSync(op, true)
3133
}
3234

35+
testUnit(
36+
"realTimeZonedDateTime should return a ZonedDateTime constructed from realTime with UTC offset") {
37+
38+
// Unfortunately since SyncIO doesn't use on a controllable
39+
// clock source, so a diff best we can do
40+
val op = for {
41+
realTime <- SyncIO.realTime
42+
now <- SyncIO.realTimeZonedDateTime
43+
} yield (
44+
(now.toInstant.toEpochMilli - realTime.toMillis) <= 10000,
45+
now.getOffset.getTotalSeconds
46+
)
47+
48+
assertCompleteAsSync(op, (true, ZoneOffset.UTC.getTotalSeconds))
49+
}
50+
3351
}
3452

3553
}

0 commit comments

Comments
 (0)