Conditions

System Testing for C

The IF statement comprises the keywords IF, THEN, ELSE, and END. It lets you define branches and follows these rules:

  • The test following the keyword IF must be a Boolean expression in C or C++.

  • IF instructions can be located in scenarios, procedures, or environment blocks.

  • The ELSE branch is optional.

The sequence IF (test) THEN must appear on a single line. The keywords ELSE and END IF must each appear separately on their own lines.

Example

HEADER "Instruction IF", "1.0", "1.0"

#int IdConnection;

SCENARIO Main

COMMENT connection

CALL socket(AF_UNIX, SOCK_STREAM, 0)@@IdConnection

IF (IdConnection == -1) THEN

EXIT

END IF

END SCENARIO

Related Topics

Iterations | Multiple Conditions | IF