nim-libp2p/tests/utils/assertions.nim

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

11 lines
375 B
Nim
Raw Normal View History

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()) =
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() & "\""