2024-08-07 19:05:33 +00:00
|
|
|
import stew/results, options
|
|
|
|
|
|
|
|
proc assertIsOk*[T, E](res: Result[T, E]) =
|
|
|
|
assert res.isOk, res.error
|
|
|
|
|
|
|
|
proc assertIsErr*[T, E](res: Result[T, E], error: Option[E] = E.none()) =
|
2024-08-14 15:39:32 +00:00
|
|
|
assert res.isErr, "Result was \"Ok\" but expected \"Err\""
|
2024-08-07 19:05:33 +00:00
|
|
|
if error.isSome():
|
|
|
|
assert res.error == error.get(),
|
|
|
|
"Result was \"" & res.error & "\" but expected \"" & error.get() & "\""
|