Skip to content

Commit

Permalink
Add tests to printing of invalid enums
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobnissen committed Jul 15, 2021
1 parent a3875e2 commit 3a259a1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/enums.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ let io = IOBuffer()
@test String(take!(io)) == sprint(print, Fruit)
end

# Test printing of invalid enums
@test repr("text/plain", reinterpret(Fruit, Int32(11))) == "<invalid #11>::Fruit = 11"
@test repr("text/plain", reinterpret(Fruit, Int32(-5))) == "<invalid #-5>::Fruit = -5"

@enum LogLevel DEBUG INFO WARN ERROR CRITICAL
@test DEBUG < CRITICAL

Expand All @@ -160,6 +164,9 @@ end
@test repr("text/plain", sevn) == "$(string(sevn))::UI8 = 0x07"
@test repr("text/plain", fiftn) == "$(string(fiftn))::UI8 = 0xf0"

@test repr("text/plain", reinterpret(UI8, 0x01)) == "<invalid #1>::UI8 = 0x01"
@test repr("text/plain", reinterpret(UI8, 0xff)) == "<invalid #255>::UI8 = 0xff"

# test block form
@enum BritishFood begin
blackpudding = 1
Expand Down

0 comments on commit 3a259a1

Please sign in to comment.