File tree 2 files changed +17
-2
lines changed
integration/kotlin/io/github/serpro69/kfaker/provider
main/kotlin/io/github/serpro69/kfaker
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package io.github.serpro69.kfaker.provider
3
3
import io.github.serpro69.kfaker.faker
4
4
import io.kotest.assertions.throwables.shouldNotThrow
5
5
import io.kotest.core.spec.style.DescribeSpec
6
+ import io.kotest.matchers.shouldBe
6
7
import io.kotest.matchers.shouldNotBe
7
8
import io.kotest.matchers.string.shouldContain
8
9
import io.kotest.matchers.string.shouldMatch
@@ -11,6 +12,17 @@ class AddressIT : DescribeSpec({
11
12
describe("Address Provider ") {
12
13
val address : (locale: String ) -> Address = { faker { fakerConfig { locale = it } }.address }
13
14
15
+ context("uk locale") {
16
+ context("empty list as a parameter value") {
17
+ it("cityPrefix() should return empty string") {
18
+ address("uk").cityPrefix() shouldBe " "
19
+ }
20
+ it("citySuffix() should return empty string") {
21
+ address("uk").citySuffix() shouldBe " "
22
+ }
23
+ }
24
+ }
25
+
14
26
context("nb-NO locale") {
15
27
it("city() does NOT throw NoSuchElementException ") {
16
28
shouldNotThrow<NoSuchElementException > { address("nb-NO ").city() }
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import io.github.serpro69.kfaker.provider.FakeDataProvider
19
19
import io.github.serpro69.kfaker.provider.Name
20
20
import io.github.serpro69.kfaker.provider.Tertiary
21
21
import io.github.serpro69.kfaker.provider.YamlFakeDataProvider
22
+ import org.w3c.dom.ranges.RangeException
22
23
import java.io.InputStream
23
24
import java.util.*
24
25
import java.util.regex.Matcher
@@ -304,8 +305,10 @@ internal class FakerService {
304
305
305
306
return when (parameterValue) {
306
307
is List <* > -> {
307
- when (val value = randomService.randomValue(parameterValue)) {
308
- is List <* > -> RawExpression (randomService.randomValue(value) as String )
308
+ if (parameterValue.isEmpty()) RawExpression (" " ) else when (val value = randomService.randomValue(parameterValue)) {
309
+ is List <* > -> {
310
+ if (value.isEmpty()) RawExpression (" " ) else RawExpression (randomService.randomValue(value) as String )
311
+ }
309
312
is String -> RawExpression (value)
310
313
is Int -> RawExpression (value.toString())
311
314
else -> throw UnsupportedOperationException (" Unsupported type of raw value: ${parameterValue::class .simpleName} " )
You can’t perform that action at this time.
0 commit comments