/*****************************************************************
 ** @author   STF 487 (updated by STF 521)
 ** @version  0.0.2
 ** @purpose  1:22.3.6, @decoded redirect value assignment with encoding parameter
 ** @verdict  pass accept, ttcn3verdict:pass
 *****************************************************************/

// The following requirements are tested:
// In case the referenced field is of the universal charstring type, the @decoded
// clause can contain 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_220306_catch_operation_014 {
	type record R {
        integer id,
        universal charstring payload
    }

    signature S() exception (R);

	type port P procedure {
		inout S;
	}

    type component GeneralComp {
		port P p;
	}

    function f_server() runs on GeneralComp {
        var integer v_src := 1953719668 with { variant "32 bit" };
        var R v_rec := { id := 5, payload := encvalue_unichar(v_src, "UTF-16LE") };
        p.getcall(S:?);
        p.raise(S, v_rec);
    }

    testcase TC_Sem_220306_catch_operation_014() runs on GeneralComp system GeneralComp {
        var integer v_res with { variant "32 bit" };
        var GeneralComp v_ptc := GeneralComp.create("PTC");
        connect(self:p, v_ptc:p);
        v_ptc.start(f_server());
        p.call(S:{}) {
            [] p.catch(S, R:?) -> value (v_res := @decoded("UTF-16LE") payload) {
                if (v_res == 1953719668) { setverdict (pass); }
                else { setverdict(fail); }
            }
            [] p.catch { setverdict(fail); }
        };
        v_ptc.done;
        setverdict(pass);
    }

    control {
        execute(TC_Sem_220306_catch_operation_014(), 5.0);
    }
}