This is an archived page. It's not actively maintained.





Throws an assertion failure if the first macro argument does not evaluate to true. In a debug build the failure text is written to console (stderr), into the NSPR debug log, and on Windows a dialog box is opened. The behavior of an assertion failure can be controlled using the XPCOM_DEBUG_BREAK environment variable.

An assertion failure should be thrown on critical program errors only. A triggered assertion failure is equivalent to crashing in Tinderbox tests.

Note on terminology: "assertion" is the condition to test. There is always an assertion in NS_ASSERTION; it is the first argument. Only if the assertion evaluates to false is there an "assertion failure", which is thrown. The phrase "throwing an assertion" makes no sense.


NS_ASSERTION(expressionToTest, "error text");

See also