[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ERT: should-error doesn't catch failed assertions

From: Sean McAfee
Subject: ERT: should-error doesn't catch failed assertions
Date: Sun, 17 Jul 2016 15:24:21 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

I've just begin trying to use ERT to write unit tests for my code.  I
got hung up almost immediately when trying to confirm that a particular
function call fails an assertion.  A simple example:

(should-error (cl-assert nil))

The assertion failure escapes the should-error form and causes a stack

Is there a way to catch assertion failures like this?

The code I'm testing implements a checksum of sorts that can only work
with strings of length exactly 5, ie:

(def my-checksum (str)
  (cl-assert (= 5 (length str)))
  ; ...

reply via email to

[Prev in Thread] Current Thread [Next in Thread]