/***************************************************
 ** @author   STF 487 (updated by STF 521)
 ** @version  0.0.2
 ** @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_001 {

	type record MessageType {
	  bitstring 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_001() runs on GeneralComp {
    var bitstring v_enc;
    var Mymessage v_testMessage;
    var MessageType Message;
    template MessageType mw_matchingTemplate:= {
        payload :=  decmatch Mymessage: {field1:= 10, field2 := '1001'B}
    }

    v_testMessage:=  {
        field1 := 10,
        field2 := '1001'B
     }

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





  messagePort.send(Message);	//send message

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

}

control{
    execute(TC_Sem_B010209_decoded_content_001());
}

}
