1
+ /*
2
+ * Copyright 2019-2025 JetBrains s.r.o. and contributors.
3
+ * Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
4
+ */
5
+
6
+ package kotlinx.datetime.test
7
+
8
+ import kotlinx.datetime.internal.getAvailableZoneIds
9
+ import kotlinx.datetime.internal.getAvailableZoneIdsFoundation
10
+ import kotlin.test.Test
11
+ import kotlin.test.assertTrue
12
+
13
+ class TimeZoneNativeTest {
14
+
15
+ @Test
16
+ fun getAvailableZoneIdsReturnsValidTimezoneSet () {
17
+ assertReturnsNonEmptySetOfTimezoneStrings(getAvailableZoneIds())
18
+ }
19
+
20
+ @Test
21
+ fun getAvailableZoneIdsFoundationReturnsValidTimezoneSet () {
22
+ assertReturnsNonEmptySetOfTimezoneStrings(getAvailableZoneIdsFoundation())
23
+ }
24
+
25
+ @Test
26
+ fun getAvailableZoneIdsContainsExpectedTimezoneIDs () {
27
+ assertAvailableZoneIdsContainsExpectedTimezoneIDs(getAvailableZoneIds())
28
+ }
29
+
30
+ @Test
31
+ fun getAvailableZoneIdsFoundationContainsExpectedTimezoneIDs () {
32
+ assertAvailableZoneIdsContainsExpectedTimezoneIDs(getAvailableZoneIdsFoundation())
33
+ }
34
+
35
+ private fun assertReturnsNonEmptySetOfTimezoneStrings (zoneIds : Set <String >) {
36
+ assertTrue(zoneIds.isNotEmpty(), " Zone IDs should not be empty" )
37
+ assertTrue(zoneIds.all { it.isNotBlank() }, " All zone IDs should be non-blank" )
38
+ assertTrue(" UTC" in zoneIds || " GMT" in zoneIds, " Should contain UTC or GMT" )
39
+ assertTrue(zoneIds.any { it.contains(" America" ) }, " Should contain America timezones" )
40
+ assertTrue(zoneIds.any { it.contains(" Europe" ) }, " Should contain Europe timezones" )
41
+ }
42
+
43
+ private fun assertAvailableZoneIdsContainsExpectedTimezoneIDs (zoneIds : Set <String >) {
44
+ val expectedZones = listOf (" GMT" , " America/New_York" , " Europe/London" , " Asia/Tokyo" , " Australia/Sydney" )
45
+ assertTrue(expectedZones.all { it in zoneIds }, " Should contain all common timezone" )
46
+ }
47
+ }
0 commit comments