2021-11-25 09:33:32 +01:00
|
|
|
import std/random
|
|
|
|
import std/sequtils
|
|
|
|
import pkg/stint
|
|
|
|
|
|
|
|
randomize()
|
|
|
|
|
|
|
|
proc example*(_: type bool): bool =
|
|
|
|
rand(0'u8..1'u8) == 1
|
|
|
|
|
|
|
|
proc example*[T: SomeInteger](_: type T): T =
|
|
|
|
rand(T)
|
|
|
|
|
|
|
|
proc example*[I: static int, T](_: type array[I, T]): array[I, T] =
|
|
|
|
for i in 0..<I:
|
|
|
|
result[i] = T.example
|
|
|
|
|
|
|
|
proc example*[T](_: type seq[T], len = 0..5): seq[T] =
|
|
|
|
let chosenlen = rand(len)
|
|
|
|
newSeqWith(chosenlen, T.example)
|
|
|
|
|
2021-12-09 10:38:34 +01:00
|
|
|
proc example*(T: type StUint): T =
|
|
|
|
T.fromBytes(array[sizeof(T), byte].example)
|
2021-11-25 09:33:32 +01:00
|
|
|
|
2021-12-09 10:38:34 +01:00
|
|
|
proc example*(T: type StInt): T =
|
|
|
|
cast[T](StUint[T.bits].example)
|