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
6666private fun KClass <* >.isArray () = java.isArray
6767private fun KClass <* >.isPrimitive () =
6868 java.isPrimitive || ! defaultType.isMarkedNullable && simpleName in arrayOf(
69+ " Boolean" ,
6970 " Byte" ,
7071 " Short" ,
7172 " Int" ,
@@ -78,6 +79,7 @@ private fun KClass<*>.isPrimitive() =
7879@Suppress(" UNCHECKED_CAST" , " IMPLICIT_CAST_TO_UNIT_OR_ANY" )
7980private fun <T : Any > KClass<T>.toDefaultPrimitiveValue (): T {
8081 return when (simpleName) {
82+ " Boolean" -> true
8183 " Byte" -> 0 .toByte()
8284 " Short" -> 0 .toShort()
8385 " Int" -> 0
Original file line number Diff line number Diff line change @@ -83,6 +83,15 @@ class CreateInstanceTest {
8383 expect(result).toBeIn(- 0.000001f .. 0.000001f )
8484 }
8585
86+ @Test
87+ fun boolean () {
88+ /* When */
89+ val result = createInstance<Boolean >()
90+
91+ /* Then */
92+ expect(result).toBe(true )
93+ }
94+
8695 @Test
8796 fun string () {
8897 /* When */
You can’t perform that action at this time.
0 commit comments