@@ -12,11 +12,14 @@ import kotlinx.cinterop.allocArray
12
12
import kotlinx.cinterop.convert
13
13
import kotlinx.cinterop.memScoped
14
14
import kotlinx.cinterop.toKString
15
+ import kotlinx.datetime.IllegalTimeZoneException
15
16
import kotlinx.datetime.TimeZone
16
17
import kotlinx.datetime.internal.root
17
18
import kotlin.test.Test
18
19
import kotlin.test.assertEquals
19
20
import platform.posix.*
21
+ import kotlin.test.assertFailsWith
22
+ import kotlin.test.assertTrue
20
23
21
24
class TimeZoneNativeTest {
22
25
@@ -35,7 +38,7 @@ class TimeZoneNativeTest {
35
38
36
39
@Test
37
40
fun correctSymlinkTest () {
38
- root = " ./linux/test/time-zone-native-test-resources/ correct-symlink/"
41
+ root = " ${ RESOURCES } correct-symlink/"
39
42
40
43
println (" PWD: ${pwd()} " )
41
44
@@ -45,9 +48,27 @@ class TimeZoneNativeTest {
45
48
46
49
@Test
47
50
fun fallsBackToUTC () {
48
- root = " ./linux/test/time-zone-native-test-resources/ missing-localtime/"
51
+ root = " ${ RESOURCES } missing-localtime/"
49
52
50
53
val tz = TimeZone .currentSystemDefault()
51
54
assertEquals(TimeZone .UTC , tz)
52
55
}
56
+
57
+ @Test
58
+ fun missingTimezoneTest () {
59
+ root = " ${RESOURCES } missing-timezone/"
60
+
61
+ val exception = assertFailsWith<IllegalTimeZoneException > {
62
+ TimeZone .currentSystemDefault()
63
+ }
64
+
65
+ assertTrue(
66
+ exception.message?.startsWith(" Could not determine the timezone ID" ) == true ,
67
+ " Exception message did not match"
68
+ )
69
+ }
70
+
71
+ companion object {
72
+ const val RESOURCES = " ./linux/test/time-zone-native-test-resources/"
73
+ }
53
74
}
0 commit comments