/*****************************************************************
 ** @author   STF 584
 ** @version  0.0.1
 ** @purpose  1:7.2, Ensure that the IUT correctly handles field reference decoding
 ** @verdict  pass accept, ttcn3verdict:pass
 *****************************************************************/

/* The following requirement is tested:
In case the string operand is of the universal charstring type and
the extended syntax with parentheses is used, the type operand can be followed by an optional parameter defining the
encoding format. The parameter shall be of the charstring type and it shall contain one of the strings allowed for
the decvalue_unichar function (specified in clause C.5.4).
*/

module Sem_0703_decoded_field_reference_011 {

type component GeneralComp {
}

type charstring PduHeader;
type integer OuterPayloadHeader;

type record PDU {
		PduHeader header,
		universal charstring outerPayload        // universal charstring
}

type record OuterPayload {
	 charstring innerPayload
}

type universal charstring InnerPayload;

testcase TC_Sem_0703_decoded_field_reference_011() runs on GeneralComp {
    // outerPayload content is "abc"
    var charstring v_testText := "abc";
    var universal charstring v_test := encvalue_unichar(v_testText, "UTF-32BE");

    // convert universal charstring (UTF-32BE)
	var PDU v_packet := {header:= "header", outerPayload := v_test};

	var InnerPayload v_payload := v_packet.outerPayload => (OuterPayload.innerPayload,"UTF-32BE");

	if ( match(v_payload,"abc")) {
		setverdict(pass);
	} else {
		setverdict(fail);
	}
}

control{
    execute(TC_Sem_0703_decoded_field_reference_011());
}

}