Jump to content

SOM Assert

From EDM2
Revision as of 18:53, 10 October 2017 by Martini (talk | contribs) (Created page with "This macro asserts that a boolean condition is true. ==Syntax== <PRE> boolean condition; long errorCode; SOM_Assert(condition, errorCode); </PRE> ==Parameters== ;...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This macro asserts that a boolean condition is true.

Syntax

boolean    condition;
long       errorCode;

SOM_Assert(condition, errorCode);

Parameters

condition (boolean)
A boolean expression that is expected to be TRUE (nonzero).
errorCode (long)
The integer error code for the error to be raised if condition is FALSE.

Return Code

Remarks

The SOM_Assert macro is used to place boolean assertions in a program:

  • If condition is FALSE, and errorCode indicates a warning-level error and SOM_WarnLevel is set to be greater than zero, then a warning message is output.
  • If condition is FALSE and errorCode indicates a fatal error, an error message is output and the process is terminated.
  • If condition is TRUE and SOM_AssertLevel is set to be greater than zero, then an informational message is output.

External (Global) Data

  long SOM_WarnLevel;   /* default = 0 */
  long SOM_AssertLevel; /* default 0 */

Expansion

If condition is FALSE, and errorCode indicates a warning-level error and SOM_WarnLevel is set to be greater than zero, then a warning message is output. If condition is FALSE and errorCode indicates a fatal error, an error message is output and the process is terminated. If condition is TRUE and SOM_AssertLevel is set to be greater than zero, then an information message is output.

Example Code

#include <som.h>
main()
{
   SOM_WarnLevel = 1;
   SOM_Assert(2==2, 29);
{

Related

Macros

  • SOM_Expect
  • SOM_Test
  • SOM_TestC