1-50 SOMobjects Base Toolkit: Programmer’s Reference Manual
SOM_Assert Macro
Purpose
Asserts that a boolean condition is true.
Syntax
void SOM_Assert (
boolean condition,
long errorCode);
Description
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 */
Parameters
condition A boolean expression that is expected to be TRUE (nonzero).
errorCode The integer error code for the error to be raised if condition is FALSE.
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
#include <som.h>
main()
{
SOM_WarnLevel = 1;
SOM_Assert(2==2, 29);
}
Related Information
Macros: SOM_Expect, SOM_Test, SOM_TestC
Commenti su questo manuale