@@ -2,6 +2,7 @@ package com.forjrking.preferences.extensions
22
33import android.content.SharedPreferences
44import org.junit.jupiter.api.Assertions.assertEquals
5+ import org.junit.jupiter.api.Assertions.assertThrows
56import org.junit.jupiter.api.BeforeEach
67import org.junit.jupiter.api.Test
78import org.mockito.kotlin.anyOrNull
@@ -49,24 +50,26 @@ internal class EditorExtKtKtTest {
4950 @Test
5051 fun getValue () {
5152 var value = mockSP.getValue(Int ::class , UNIT_TYPE , key, 0 )
52- assertEquals(1 , value)
53+ assertEquals(1 , value)
5354 value = mockSP.getValue(Float ::class , UNIT_TYPE , key, 0F )
54- assertEquals(1F , value)
55+ assertEquals(1F , value)
5556 value = mockSP.getValue(Long ::class , UNIT_TYPE , key, 0L )
56- assertEquals(1L , value)
57+ assertEquals(1L , value)
5758 value = mockSP.getValue(String ::class , UNIT_TYPE , key, null )
58- assertEquals(" ABC" , value)
59+ assertEquals(" ABC" , value)
5960 }
6061
6162 @Test
6263 fun getValueObj () {
6364 val value = mockSP.getValue(Set ::class , typeOf<Set <String >>().javaType, key, null )
64- assertEquals(null , value)
65+ assertEquals(null , value)
6566 }
6667
6768 @Test
6869 fun `getValueObj not support` () {
69- val value = mockSP.getValue(Set ::class , typeOf<Set <Long >>().javaType, key, null )
70- assertEquals(null , value)
70+ assertThrows(IllegalStateException ::class .java) {
71+ val value = mockSP.getValue(Set ::class , typeOf<Set <Long >>().javaType, key, null )
72+ assertEquals(null , value)
73+ }
7174 }
7275}
0 commit comments