Skip to content

Commit

Permalink
included literal 'null' check for regex as it has similar issue as Js…
Browse files Browse the repository at this point in the history
…onValue.Null
  • Loading branch information
Ryan Levell committed Feb 28, 2021
1 parent e3bd289 commit 20f53c6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ fun <M : Mismatch> matchRegex(
actual: Any?,
mismatchFactory: MismatchFactory<M>
): List<M> {
val matches = if (actual is JsonValue.Null) false else safeToString(actual).matches(Regex(regex))
val matches = if (actual == null || actual is JsonValue.Null) false else safeToString(actual).matches(Regex(regex))
logger.debug { "comparing ${valueOf(actual)} with regexp $regex at $path -> $matches" }
return if (matches ||
expected is List<*> && actual is List<*> ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class MatcherExecutorSpec extends Specification {
'100' | new JsonValue.Integer('20123'.chars) | '\\d+' || true
json('"harry100"') | json('"20123happy"') | '[a-z0-9]+' || true
json('"issue1316"') | JsonValue.Null.INSTANCE | '[a-z0-9]+' || false
json('"issue1316"') | null | '[a-z0-9]*' || false
}

@Unroll
Expand Down

0 comments on commit 20f53c6

Please sign in to comment.