Skip to content

Commit

Permalink
Fix test_json_marshalling
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Jun 10, 2024
1 parent 4205a2f commit ae2c8c7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test_json_marshalling.nim
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ proc rand[T](_: type seq[T]): seq[T] =
proc rand[T](_: type SingleOrList[T]): SingleOrList[T] =
SingleOrList[T](kind: slkSingle, single: rand(T))

proc rand[X](T: type Opt[X]): T =
var x: array[1, byte]
discard randomBytes(x)
if x[0] > 127:
result = Opt.some(rand(X))
else:
result = Opt.none(X)

proc rand[X: object](T: type X): T =
result = T()
for field in fields(result):
Expand Down

0 comments on commit ae2c8c7

Please sign in to comment.