File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
main/kotlin/com/nhaarman/mockito_kotlin Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ private fun KClass<*>.isEnum() = java.isEnum
66
66
private fun KClass <* >.isArray () = java.isArray
67
67
private fun KClass <* >.isPrimitive () =
68
68
java.isPrimitive || ! defaultType.isMarkedNullable && simpleName in arrayOf(
69
+ " Boolean" ,
69
70
" Byte" ,
70
71
" Short" ,
71
72
" Int" ,
@@ -78,6 +79,7 @@ private fun KClass<*>.isPrimitive() =
78
79
@Suppress(" UNCHECKED_CAST" , " IMPLICIT_CAST_TO_UNIT_OR_ANY" )
79
80
private fun <T : Any > KClass<T>.toDefaultPrimitiveValue (): T {
80
81
return when (simpleName) {
82
+ " Boolean" -> true
81
83
" Byte" -> 0 .toByte()
82
84
" Short" -> 0 .toShort()
83
85
" Int" -> 0
Original file line number Diff line number Diff line change @@ -83,6 +83,15 @@ class CreateInstanceTest {
83
83
expect(result).toBeIn(- 0.000001f .. 0.000001f )
84
84
}
85
85
86
+ @Test
87
+ fun boolean () {
88
+ /* When */
89
+ val result = createInstance<Boolean >()
90
+
91
+ /* Then */
92
+ expect(result).toBe(true )
93
+ }
94
+
86
95
@Test
87
96
fun string () {
88
97
/* When */
You can’t perform that action at this time.
0 commit comments