Multiple Conditions

System Testing for C

The multiple-condition statement CASE comprises the keywords CASE, WHEN, END, OTHERS and the arrow symbol =>.

CASE instructions follow these rules:

  • The test following the keyword CASE must be a C or C++ Boolean expression. The keyword WHEN must be followed by an integer constant.

  • The keyword OTHERS indicates the default branch for the CASE instruction. This branch is optional.

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

Example

HEADER "Instruction CASE", "", ""

...

MESSAGE message_t: response

SCENARIO One

...

CALL mbx_send_message(&id,&message) @ err_ok

DEF_MESSAGE response, EV={}

WAITTIL(MATCHING(response),WTIME == 10)

-- Checking the just received event type

CASE (response.type)

WHEN ACK =>

CALL mbx_send_message(&id,&message) @ err_ok

WHEN DATA =>

CALL mbx_send_message(&id,&ack) @ err_ok

WHEN NEG_ACK =>

CALL mbx_send_message(&id,&error) @ err_ok

WHEN OTHERS => ERROR

END CASE

END SCENARIO

Related Topics

Conditions | Iterations | System Testing language reference | CASE