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:

 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

ConditionsIterationsSystem Testing language referenceCASE