-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'FasterXML/2.17'
- Loading branch information
Showing
6 changed files
with
128 additions
and
5 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
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
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
117 changes: 117 additions & 0 deletions
117
src/test/kotlin/tools/jackson/module/kotlin/test/VarargDeserTest.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,117 @@ | ||
package tools.jackson.module.kotlin.test | ||
|
||
import junit.framework.TestCase.assertEquals | ||
import junit.framework.TestCase.assertTrue | ||
import org.junit.Ignore | ||
import org.junit.experimental.runners.Enclosed | ||
import org.junit.runner.RunWith | ||
import tools.jackson.module.kotlin.jacksonObjectMapper | ||
import tools.jackson.module.kotlin.readValue | ||
import kotlin.test.Test | ||
|
||
// from https://github.com/ProjectMapK/jackson-module-kogera/blob/0631cd3b07c7fb6971a00ac1f6811b4367a1720e/src/test/kotlin/io/github/projectmapk/jackson/module/kogera/zIntegration/deser/VarargTest.kt#L1 | ||
@RunWith(Enclosed::class) | ||
class VarargDeserTest { | ||
@Ignore | ||
companion object { | ||
val mapper = jacksonObjectMapper() | ||
} | ||
|
||
@Ignore | ||
class OnlyVararg(vararg val v: Int) | ||
|
||
class OnlyVarargTest { | ||
@Test | ||
fun hasArgs() { | ||
val r = mapper.readValue<OnlyVararg>("""{"v":[1,2,3]}""") | ||
assertEquals(listOf(1, 2, 3), r.v.asList()) | ||
} | ||
|
||
@Test | ||
fun empty() { | ||
val r = mapper.readValue<OnlyVararg>("""{"v":[]}""") | ||
assertTrue(r.v.isEmpty()) | ||
} | ||
|
||
@Test | ||
fun undefined() { | ||
val r = mapper.readValue<OnlyVararg>("""{}""") | ||
assertTrue(r.v.isEmpty()) | ||
} | ||
} | ||
|
||
@Ignore | ||
class HeadVararg(vararg val v: Int?, val i: Int) | ||
|
||
class HeadVarargTest { | ||
@Test | ||
fun hasArgs() { | ||
val r = mapper.readValue<HeadVararg>("""{"i":0,"v":[1,2,null]}""") | ||
assertEquals(listOf(1, 2, null), r.v.asList()) | ||
assertEquals(0, r.i) | ||
} | ||
|
||
@Test | ||
fun empty() { | ||
val r = mapper.readValue<HeadVararg>("""{"i":0,"v":[]}""") | ||
assertTrue(r.v.isEmpty()) | ||
assertEquals(0, r.i) | ||
} | ||
|
||
@Test | ||
fun undefined() { | ||
val r = mapper.readValue<HeadVararg>("""{"i":0}""") | ||
assertTrue(r.v.isEmpty()) | ||
assertEquals(0, r.i) | ||
} | ||
} | ||
|
||
@Ignore | ||
class TailVararg(val i: Int, vararg val v: String) | ||
|
||
class TailVarargTest { | ||
@Test | ||
fun hasArgs() { | ||
val r = mapper.readValue<TailVararg>("""{"i":0,"v":["foo","bar","baz"]}""") | ||
assertEquals(listOf("foo", "bar", "baz"), r.v.asList()) | ||
assertEquals(0, r.i) | ||
} | ||
|
||
@Test | ||
fun empty() { | ||
val r = mapper.readValue<TailVararg>("""{"i":0,"v":[]}""") | ||
assertTrue(r.v.isEmpty()) | ||
assertEquals(0, r.i) | ||
} | ||
|
||
@Test | ||
fun undefined() { | ||
val r = mapper.readValue<TailVararg>("""{"i":0}""") | ||
assertTrue(r.v.isEmpty()) | ||
assertEquals(0, r.i) | ||
} | ||
} | ||
|
||
@Ignore | ||
class HasDefaultVararg(vararg val v: String? = arrayOf("foo", "bar")) | ||
|
||
class HasDefaultVarargTest { | ||
@Test | ||
fun hasArgs() { | ||
val r = mapper.readValue<HasDefaultVararg>("""{"v":["foo","bar",null]}""") | ||
assertEquals(listOf("foo", "bar", null), r.v.asList()) | ||
} | ||
|
||
@Test | ||
fun empty() { | ||
val r = mapper.readValue<HasDefaultVararg>("""{"v":[]}""") | ||
assertTrue(r.v.isEmpty()) | ||
} | ||
|
||
@Test | ||
fun undefined() { | ||
val r = mapper.readValue<HasDefaultVararg>("""{}""") | ||
assertEquals(listOf("foo", "bar"), r.v.asList()) | ||
} | ||
} | ||
} |