Skip to content

Commit

Permalink
Merge pull request #5 from nhaarman/release-0.1.5
Browse files Browse the repository at this point in the history
Release 0.1.5
  • Loading branch information
nhaarman committed Jan 24, 2016
2 parents 0665c25 + 8157be6 commit 37ded6f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private fun KClass<*>.isEnum() = java.isEnum
private fun KClass<*>.isArray() = java.isArray
private fun KClass<*>.isPrimitive() =
java.isPrimitive || !defaultType.isMarkedNullable && simpleName in arrayOf(
"Boolean",
"Byte",
"Short",
"Int",
Expand All @@ -78,6 +79,7 @@ private fun KClass<*>.isPrimitive() =
@Suppress("UNCHECKED_CAST", "IMPLICIT_CAST_TO_UNIT_OR_ANY")
private fun <T : Any> KClass<T>.toDefaultPrimitiveValue(): T {
return when (simpleName) {
"Boolean" -> true
"Byte" -> 0.toByte()
"Short" -> 0.toShort()
"Int" -> 0
Expand Down
9 changes: 9 additions & 0 deletions mockito-kotlin/src/test/kotlin/CreateInstanceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ class CreateInstanceTest {
expect(result).toBeIn(-0.000001f..0.000001f)
}

@Test
fun boolean() {
/* When */
val result = createInstance<Boolean>()

/* Then */
expect(result).toBe(true)
}

@Test
fun string() {
/* When */
Expand Down

0 comments on commit 37ded6f

Please sign in to comment.