Sem_B010209_decoded_content_004.ttcn 1.57 KB
Newer Older
kovacsa's avatar
kovacsa committed
/***************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:B.1.2.8, Ensure that the IUT correctly handles content decoding 
 ** @verdict  pass accept, ttcn3verdict:pass
 ***************************************************/

//Restriction a)
/*It can be assigned to templates and template fields of bitstring, hexstring, octetstring,
charstring and universal charstring types.*/


module Sem_B010209_decoded_content_004 { 

	type record MessageType {
	  charstring payload
	}
	
	type record Mymessage {
	  integer field1,
	  bitstring field2 optional
    }
	

    type port loopbackPort message{inout MessageType};
	

type component GeneralComp {	    	    
	  port loopbackPort messagePort
}	

testcase TC_Sem_B010209_decoded_content_004() runs on GeneralComp {
    var bitstring v_enc;
    var Mymessage v_testMessage;
    var MessageType Message;
    
    v_testMessage:=  {  
        field1 := 10,
        field2 := '1001'B
     } 

      Message.payload := bit2str(encvalue(v_testMessage));		//encode message to payload, charstring
          
    
    

 template MessageType mw_matchingTemplate:=
  {  			
  payload :=  decmatch Mymessage: {field1:= 10, field2 := '1001'B}
  } 


  messagePort.send(Message);	//send message

    alt {
     [] messagePort.receive(mw_matchingTemplate) {
        setverdict(pass);
     }
     [] messagePort.receive {
        setverdict(fail,mw_matchingTemplate);
     }
    }
    
}

control{
    execute(TC_Sem_B010209_decoded_content_004());
}

}