Skip to content

Commit

Permalink
Fix sampling of malformed Char
Browse files Browse the repository at this point in the history
  • Loading branch information
Seelengrab committed Apr 9, 2024
1 parent 74ce9ee commit de3bbed
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,12 @@ produce!(tc::TestCase, r::Recursive) = produce!(tc, r.inner)
## Possibility of Characters

"""
Characters(;valid::Bool = false, malformed=true) <: Possibility{Char}
Characters(;valid::Bool = false, malformed = true) <: Possibility{Char}
A `Possibility` of producing arbitrary `Char` instances.
!!! warning "Unicode"
This will `produce!` ANY possible `Char` by default, not just valid unicode codepoints!
This will `produce!` ANY possible `Char` by default, not just valid or well-formed unicode codepoints!
To only produce valid unicode codepoints, pass `valid=true` as a keyword argument.
To produce well-formed (but not necessarily valid) unicode codepoints, pass `malformed=false`.
Expand Down Expand Up @@ -644,7 +644,9 @@ function produce!(tc::TestCase, c::Characters)
sample = SampledFrom(typemin(Char):'\U0010ffff')
s = filter(isvalid, sample)
elseif c.malformed
s = SampledFrom(typemin(Char):typemax(Char))
s = map(Data.Integers{UInt32}()) do i
reinterpret(Char, i)
end
else
s = SampledFrom(typemin(Char):"\xf7\xbf\xbf\xbf"[1])
end
Expand Down

0 comments on commit de3bbed

Please sign in to comment.