Skip to content

Commit 3a259a1

Browse files
committed
Add tests to printing of invalid enums
1 parent a3875e2 commit 3a259a1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/enums.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ let io = IOBuffer()
143143
@test String(take!(io)) == sprint(print, Fruit)
144144
end
145145

146+
# Test printing of invalid enums
147+
@test repr("text/plain", reinterpret(Fruit, Int32(11))) == "<invalid #11>::Fruit = 11"
148+
@test repr("text/plain", reinterpret(Fruit, Int32(-5))) == "<invalid #-5>::Fruit = -5"
149+
146150
@enum LogLevel DEBUG INFO WARN ERROR CRITICAL
147151
@test DEBUG < CRITICAL
148152

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

167+
@test repr("text/plain", reinterpret(UI8, 0x01)) == "<invalid #1>::UI8 = 0x01"
168+
@test repr("text/plain", reinterpret(UI8, 0xff)) == "<invalid #255>::UI8 = 0xff"
169+
163170
# test block form
164171
@enum BritishFood begin
165172
blackpudding = 1

0 commit comments

Comments
 (0)