forked from kotest/kotest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't consider kotlinx and javax types to be builtin (kotest#3899)
Fixes kotest#3855 --------- Co-authored-by: Sam <sam@sksamuel.com>
- Loading branch information
Showing
5 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...tions/kotest-assertions-core/src/jvmMain/kotlin/io/kotest/matchers/equality/primitives.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.kotest.matchers.equality | ||
|
||
/** | ||
* This is currently unused but will form the basis of reflection based checks in 6.0 | ||
*/ | ||
internal fun <T> T.isBuiltInType() = | ||
this is Number | ||
|| this is UInt | ||
|| this is ULong | ||
|| this is UByte | ||
|| this is UShort | ||
|| this is String | ||
|| this is Boolean | ||
|| this is Char | ||
|| this is IntArray | ||
|| this is CharArray | ||
|| this is LongArray | ||
|| this is ShortArray | ||
|| this is ByteArray | ||
|| this is DoubleArray | ||
|| this is FloatArray | ||
|| this is BooleanArray | ||
|| this is UIntArray | ||
|| this is ULongArray | ||
|| this is UByteArray | ||
|| this is UShortArray | ||
|| this is Array<*> | ||
|| this is List<*> | ||
|| this is Set<*> | ||
|| this is Map<*, *> | ||
|| this is Sequence<*> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
kotest-tests/kotest-tests-core/src/jvmTest/kotlin/com/sksamuel/kotest/JaxbElementTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.sksamuel.kotest | ||
|
||
import io.kotest.assertions.shouldFail | ||
import io.kotest.core.spec.style.FunSpec | ||
import io.kotest.matchers.equality.shouldBeEqualToComparingFields | ||
import io.kotest.matchers.string.shouldContain | ||
import javax.xml.bind.JAXBElement | ||
import javax.xml.namespace.QName | ||
|
||
class JaxbElementTest : FunSpec({ | ||
|
||
context("Comparing JAXBElement reflectively works as expected") { | ||
|
||
val jaxbElement = JAXBElement(QName.valueOf("name"), Int::class.java, 123) | ||
val otherJaxbElement = JAXBElement(QName.valueOf("name"), Int::class.java, 124) | ||
|
||
test("!should pass when comparing equal elements") { | ||
jaxbElement.shouldBeEqualToComparingFields(jaxbElement) | ||
} | ||
|
||
test("!should fail when comparing different elements") { | ||
shouldFail { | ||
jaxbElement.shouldBeEqualToComparingFields(otherJaxbElement) | ||
}.message.shouldContain( | ||
"""Value differ at:\s+1\) value:\s+expected:<124> but was:<123>""".toRegex() | ||
) | ||
} | ||
} | ||
}) |